0

In my custom portlet this is my view.jsp :

    <h1>Liferay auto fields example</h1>
<form action="" method="post" name="LiferayAautoFieldForm">
<fieldset><legend>Phone Numbers</legend>
<div id="phone-fields">
<div class="lfr-form-row lfr-form-row-inline">
<div class="row-fields">
<input id='phoneNumber0' name="phoneNumber0" label="Phone Number" />
<select id="phoneTypeId0" name="phoneTypeId0" label="Type">
<option value="11006" label="Business">Business</option>
<option value="11007" label="Business Fax">Business Fax</option>
<option value="11008" label="Mobile Phone">Mobile Phone</option>
<option value="11009" label="Other">Other</option>
<option value="11011" label="Personal">Personal</option>
</select>
</div>
</div>
</div>
</fieldset>
<layout>
<column>
<button type="submit" value="Save Phone Numbers" name="SavePhoneNumbers">Save Phone Numbers</button>
</column>
</layout>
</form>

I want to use new Liferay.AutoFields among tag for increasing these two fields. For this aim I use this code in view.jsp :

<aui:script use="liferay-auto-fields">
new Liferay.AutoFields(
{
contentBox: '#phone-fields',
fieldIndexes: 'phonesIndexes'
}
).render();
</aui:script>

But It has problem, after add this code and deploy my portlet I can add/delete row but after adding some rows and delete them the id of phoneNumber0 becomes wrong. Actually the sequence of phoneNumber0 doesn't regular!

How can I solve this issue? Please guide me?

brelian
  • 403
  • 2
  • 15
  • 31
  • What is the exact issue you are facing?? – Pankaj Kathiriya Jan 05 '14 at 07:25
  • @PankajKathiriya, after add some new rows the id of the input regularly increase phoneNumber0,1,2,... but after delete some rows this sequence mixed and for the next time that I want to add row I have not a reqular sequence – brelian Jan 05 '14 at 08:46
  • 1
    Hi my auto field is working perfectly if I add only input type text and select list, but when I am adding a button then after addition newly created button id is same as previous one, other field id is incrementing by one as usual. please help me to resolve this issue. – asifaftab87 Sep 18 '14 at 09:23

1 Answers1

1

You can refer to the Liferay source to use "liferay-auto-fields".

ROOT\html\portlet\users_admin\common\phone_numbers.jsp.

They have used auto fields for similar requirement as yours.

Atin
  • 5
  • 2