Friday, October 19, 2012

Adding custom field in registration page is Liferay

Hi, guys Liferay is such a beautiful portal technology, it has one pretty nice feature about custom fields.

This post is how to use that custom field feature in registration field in liferay

Here are the steps to be followed
1. Click on control panel > User > Custom attributes > Add Custom attributes.

2. Here we need to give a key (name) and type of the field.  

3. For eg. We will have an Field called Designation added which is a text field. 
    Key :   Designation
    Type : Text-field(Indexed) and save. 

4. Then add the custom attribute taglib in the create_account.jsp in /tomcat/webapps/ROOT/html/portlet/login as follows:

<liferay-ui:custom-attribute-list

            className="com.liferay.portal.model.User"

            classPK="<%= 0l %>"

            editable="<%= true %>"

            label="<%= true %>"

      /> 
    But this field will not appear on the create account page because permissions are not given.


   Hence to permission click on action tab of that custom attribute(here eg.Designation) and permissions

 Note: very important thing is assigning permission for added custom field to guest

    1. Here for guest we give permission for view and update.
  
    2. Now in the create account page this field will appear.


And you can get those value in expando table in liferay, you can fetch the value using expandoBridge class.