Advanced Form Field fragment collection

Marketplace

Hi there!

Over time, I've built myself a collection of simple but useful fragments I'm using all the time when using Form Containers.

I've decided to contribute them as a marketplace application in order to make it easier to add them to my Liferay workspaces:

https://marketplace.liferay.com/p/advanced-form-field-fragments

Soon, it's going to be even easier to load marketplace apps from Liferay. For example, you'll be able to load that fragment set directly from the fragment menu.

Now, here's a description of what those form fragments will achieve.

 

Here's some sample object model about Events and Registrations.

I've created a page with a Collection Display fragment listing all those events.

The Register button will open the default Display Page Template of the selected Event.

A Form Container bound to the Registration object is here. Its purpose is to collect the Email Address, First name and Last name but also the Event Registration relationship.

This relationship should be implicit, right? We shouldn't ask the user to select the Event from a dropdown as we are already on the display page of the event.

This is where the first one of my fragments comes into play. It's called Current Object Entry.


As you can see above, it's a hidden form field, bound to the relationship. What it does is populate a hidden <input /> field with the value of the object entry ID we fetch from the request context using some freemarker.

The other fragments I have provided work the same way.

For example, here's the Query Parameter Value fragment:

Instead of reading the object entry ID from the request context, that one is capable of reading a query parameter in the URL and write it in the value of a hidden input field, again.

The Referer Value fragment is similar but reads some value from the Referer header of the HTTP Request.

Finally, the Current Account fragment is one I have created in a commerce context. Within a commerce channel, there's a built-in Account Selector fragment you can use which lets you switch the current account.

The Current Account fragment will read the current account ID from the commerce context (works only on a site bound to a channel) and make it available in a hidden input field.

 

There are probably a lot more form field utilities we can build using the same pattern. I'll probably add more of them, so watch for future updates!