cancel
Showing results for 
Search instead for 
Did you mean: 

How to Add Dynamic Fields in AIkau Form ?

jayachender
Confirmed Champ
Confirmed Champ

Hi I have three fields in a form when i click on add button i want to add dynamically that four fields.FYI i attached the screenshot below.

Thanks,

Jayachender

5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator

I guess using a DynamicForm might be an option in this case. A custom service / composite widget containing both the actual form as well as your "add new form control" elements could be developed to handle the necessary state, e.g. record the form value and react to the "Add" / "Remove" buttons to trigger the topic for re-drawing the actual form with previous and added/removed fields.

Though this option is not simple enough to provide you with ready-made sample code snippets, it should be fairly straight-forward to achieve if you have familiarized yourself with the Aikau pubSub concept and how custom widget modules can be defined.

Thanks for your Reply Axel.

ddraper
World-Class Innovator
World-Class Innovator

Looking at your screenshot it might be that you're looking for the MultipleEntryFormControl. This form control is essentially a "form within a form"... so you can add, edit and remove repeating data within the form. If you set up the Aikau unit test application you can try it out in the unit test page.

You can also see an example of this in the Search Manager page in Share when configuring factets (and choosing which site specific search the facet should be used on).

Yes Dave,

I already tried your approach.But according to bushiness requirement they want.

That MultipleEntryFormControl i tried like below its working fine.

Apart from this do we have any in AIKAU dynamic addition of fields in form?

Thanks,

Jay

ddraper
World-Class Innovator
World-Class Innovator

Well, you could use the DynamicWidgets element to contain your form and then publish different models to it... it's not exactly what you're looking for, but might provide a potential workaround.

There is always the progressive disclosure option as provided by the visibilityConfig attribute on all fields - but this is simply revealing widgets that would have always been there rather than actually creating new one.

There is no ability to actually add additional fields into a form... however, it would be a relatively simple exercise to extend the existing Form widget and provide the capability yourself. You would need to extend the postCreate function to create a new subscription to a topic that would be used to create the form controls. The callback handler for that function would need to create the required form controls within the DOM node of the inner form.