Legacy Knowledge Base
Published Jul. 2, 2025

Not able to create custom form field

Written By

Ankit Gupta

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • While trying to create a custom form field using Liferay Developer Studio 3.8.1.
    LDS shows an error "Specified Liferay version is invalid. Must be in range [7.0.0,7.2.0)"

Environment

  • Liferay DXP 7.2

Resolution

  • The issue will be fixed in the upcoming fix-pack where the complete and rigorous will be done. In the meantime, the below workaround can be followed:

    1. Updated Blade to the snapshot:
    D:\Workspace>blade update -s
    Current blade version 3.10.0.SNAPSHOT202005212038 is greater than the latest snapshot version.
    D:\Workspace>blade version
    blade version 3.10.0.SNAPSHOT202005212038
    2. Then created a folder called "workspace", stepped into it, and created a new Liferay Workspace (for DXP 7.2) in it:

    D:\Workspace>blade init -f -v 7.2

    3. Then created the form field module:
    D:\Workspace>blade create -t form-field -p com.liferay.my.form.field -c MyFormField my-form-field
    Successfully created project my-form-field in D:\Workspace\modules
    4. Then stepped into the module folder and tried to build it:
    D:\Workspace>cd modules

    D:\Workspace\modules>cd my-form-field

    D:\Workspace\modules\my-form-field>..\..\gradlew build


    > Task :modules:my-form-field:compileJava FAILED
    D:\Workspace\modules\my-form-field\src\main\java\com\liferay\my\form\field\form\field\MyFormFieldDDMFormFieldRenderer.java:30: error: missing return statement
            }
            ^
    1 error
    As you can see, this error in MyFormFieldDDMFormFieldRenderer.java because strangely, the getTemplateNamespace method lacked a return statement (it was completely empty). So, kindly add the below line MyFormFieldDDMFormFieldRenderer.java. 
    return "my-form-field";

    so please put it in my file and tried to build it again. Now the build will be successful.

    5. Now needed a DXP server where this jar file could be deployed. So took a vanilla DXP 7.2 SP1.

    6. After it started up,  simply copied the com.liferay.my.form.field-1.0.0.jar file to its deploy folder, and the deployment happened successfully. I saw this in the Tomcat console:
    2020-05-26 09:19:50.545 INFO  [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:259] Processing com.liferay.my.form.field-1.0.0.jar
    2020-05-26 09:19:58.295 INFO  [fileinstall-D:/Ticket/PIDI/liferay-dxp-7.2.10.1-sp1/osgi/modules][BundleStartStopLogger:39] STARTED com.liferay.my.form.field_1.0.0 [1099]
Did this article resolve your issue ?

Legacy Knowledge Base