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.
 
 

 

2 comments:

  1. Can you please write a blog on how to make custom fields that are usable for all users. To explain myself; If I make changes on Liferay Portal -> Control Panel... Only on my computer changes and newly made custom fields will be visible, if anyone else uses my hook will again need to create exact same custom fields to work. How to fix this?

    ReplyDelete
    Replies
    1. Dear Amir,

      I have mentioned about these things in Note of my blog. i,e You should give VIEW and UPDATE permission for guest, then it will be visible for all users.Let me know still if you find a difficulty...

      Delete