Forms in DXP

As we all know, Liferay 7 (DXP) come with new features/improvements including functional/architectural. One of them is forms which is an improved version of Kaleo Forms, DDL. Kaleo forms and DDL is having limited capabilities and good for few use cases.

DXP now provides simple way for content creators to create forms. It is much like adding content on the page. Its easy to modify any field/attribute of the form by publishing it again. There are lot of extra features like: Multisteps form, multi layout, validation, data providers etc, will explain them with a real example using Registration form :

1. You can add new forms by navigation to Menu > Content > Forms. Adding a new form name as “Registration form”. Adding fields need to capture for registration :

 

 

2. Each field comes with configuration attributes, for example text field has these attributes :

Label:  Field Label

Help Text: Help text to explain user, what this field about.

Single Line/Multiple Line: Define if field value can contain single line or multiple lines.

Required: Mandatory fields

Predefined value: Default value of field

Placeholder text: Text to assist user, not submitted actually.

Field Visibility Expression: Condition to display a field

Enable Validation: Extra validation like contains/does not contain URL, email etc for text and less than, greater than, equals etc for numbers. Default is false

There are functions and operators for your use in your field visibility expressions like between, equals, sum etc.

Show Label: If you don’t want to show label to end user, by default its true.

Repeatable: If field is repetitive. Default is false

3. By adding few fields over first page of registration, I am done with my basic registration fields but now I need to add few more fields related to education over next page “Education details” as adding all fields over same page is not User friendly. DXP forms provide multistep forms where you can achieve this :

 

4. Now in “Education Details” screen, I need University list from where employee has completed his education. I can define that list using basic select dropdown but I need it to be dynamic so that dropdown will be always updated with new Universities. Here DXP provide “Data Providers”, using that you can populate select box values dynamically. You can provide REST data providers and define display and stored JSON attribute. You can create “Data providers” using top most icon (right side) > Data providers.

5. Now this data provider can be used in “Registration form” to display university detail field.

6. Other features of the forms :

Captcha: You can enable Captcha for form submission

Redirect URL on success:  Landing page after successful form submission

Storage type (json by default): How to store form into DB, can write custom method for storing form data.

Workflow: kaleo workflow definition to be used by form

Email notification: You can configure email trigger after form submission.

View Entries: You can see all submitted application specific to form.

7.  Multi layout is also configurable by dragging out fields:

Forms vs DDL :

 

 

博客
Good article. One question though. How do you make a update to a submitted DXP form? In DDL forms its is easy, but I can not find a way in DXP forms. If I reject the form in workflow, there does not appear to be a way for the submitter to make an update.
Hi Ankit,

Can we upload file while creation form layout? I can not see file upload option. Can you please guide.

Thanks & Regards,
Bhavik
Hi Bhavik,

Yes, it is not there OOTB but Liferay makes it easy for us to add any number/type of fields using "form-field" module. Please refer:

https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/form-field-types

Thanks,
Ankit
Hi Ankit,

I am not able to open mentioned URL. I am looking into below URL.
https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/creating-form-field-types

Also I am looking into DDMFormFieldType class where I can't see File type.
I can see only DOCUMENT_LIBRARY = "ddm-documentlibrary" as field type.
Hi ankit i have a question.what if i wanted to add custom validation to the fields can i do that if yes can you please share how to do it.

Hello,

 

Can we customize the default notification mail received after each form entry? For example, when a user submits the form, a notification mail gets triggered with site name on the first line, followed by name of the person who created form on that site. This is followed by content of the mail. Thus, please suggest ways with which we can modify the mail received.

 

Thanks

Taruchit

Hi Ankit,

 

Number validations are not working 100%. I gave mobile number validation & I select (Is greater than 0). Its not allowing more than 9 digits. If I am wrong please correct me.

 

Is there any option to write our own (regex) validations ? 

 

Thanks & Best Regards,

Mufas