简体   繁体   中英

Liferay custom field validation in admin web content

I have added custom fields in admin web content from control panel in liferay 6.1.

Now I am trying to make those fields mandatory. How can I do this?

You can't. Custom fields are by-design optional in Liferay.

Another solution to your problem could be to use structured web content and to define your custom fields as structure fields. In Liferay 6.1, structured fields have several new options, such as marking them as required .

Eg suppose you want to add "Source" information to each web content, then create a new web content structure with the following XSD:

<root>
    <!-- other fields... -->
    <dynamic-element name='source' type='text' repeatable='false'>
        <meta-data>
            <entry name="displayAsTooltip"><![CDATA[true]]></entry>
            <entry name="required"><![CDATA[true]]></entry>
            <entry name="instructions"><![CDATA[News agency this article is coming from]]></entry>
            <entry name="label"><![CDATA[Source]]></entry>
            <entry name="predefinedValue"><![CDATA[]]></entry>
        </meta-data>
    </dynamic-element>
</root>

If you create new articles based on this structure, the content editor must enter a Source for the article or else Liferay will show an error message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM