0
votes

I'm starting to use the liferay-auto-fields composant.

So here is my jsp with the aui:script -->

   <aui:form action="<%=saveMotiveURL%>" name="fm" method="post" enctype="multipart/form-data" onSubmit="setZones()" >
            <aui:fieldset>
                <aui:field-wrapper>
                     <div id="emailAdress-fields">
                           <label class="control-label"><liferay-ui:message key="motiveConfigEdit.col5"></liferay-ui:message> </label>
                           <div class="lfr-form-row lfr-form-row-inline">
                               <div class="row-fields">
                                   <aui:input type="text" name="emailAdress1" fieldParam='emailAdress1' id='emailAdress1' label="" value=""/>
                                   <aui:input type="hidden" name="motiveEmailId1" fieldParam='motiveEmailId1' id='motiveEmailId1' value=""/>
                               </div>
                          </div>
                      </div>
                      <aui:button type="submit" name="saveButton" value="button.create" label=""/>
                </aui:field-wrapper>
            </aui:fieldset>
        </aui:form>
    <aui:script>

        AUI().use('liferay-auto-fields',function(A) {
            new Liferay.AutoFields(
                {
                    contentBox: '#emailAdress-fields',
                    fieldIndexes: '<portlet:namespace />rowIndexes'
                }
            ).render();
        });
</aui:script>

Then, i want to retrieve the "rowIndexes" in the processaction function, so i do :

String rowIndexes = actionRequest.getParameter("rowIndexes");

And this always gives me EMPTY. I notice also that the hidden field in the jsp 'rowIndexes' doesn't change or have value when i had an autofield by clicking on the "+" button.

Is anyone has a solution ?

thanks

1
hi there, I remember that the first few versions of liferay 7.x had auto fields completely broken, could you please tell which version are you using?Victor
Version Liferay 7.1DyM

1 Answers

0
votes

There are a couple of issues with your code you would like to address,

  • aui is deprecated and you should avoid when possible

prefer tags like

 <liferay-frontend:edit-form> 
 <liferay-frontend:edit-form-body>
 <liferay-frontend:fieldset-group>      
 <liferay-frontend:fieldset>

The following structure should work on the latest versions of Liferay:

        <liferay-frontend:fieldset >
            <div id='emailAdress-fields'>
                <div class='lfr-form-row lfr-form-row-inline'>
                    <div class='row-fields'>

                    </div>
                </div>
            </div>
        </liferay-frontend:fieldset>

Your script seems fine

<aui:script use='aui-base'>
    A.use('liferay-auto-fields',function(A) {
        new Liferay.AutoFields({
            contentBox: '#emailAdress-fields',
            fieldIndexes: '<portlet:namespace/>rowIndexes'
        }).render();
    })
</aui:script>