Quick links: Content - sections - sub sections
EN FR
Quick Search Advanced search
 
Page

  [Opened] Adding multiple fields dinamically to a jForm

Posted by fluid on 03/06/2014 14:46

Hi, I'm a bit new with the framework and I have a following problem:

I'm making an interface with jForms with various input fields... and for one of the fields I would like to add a possibility for the user to add or remove a field example.

Input fields Group------------------------------|

Input field ID: <---INPUT FIELD---> 
                   "Add another"     

------------------------------------------------|

and after you click add another you would have


Input fields Group------------------------------|

Input field ID  : <---INPUT FIELD--->  

Input field ID+1: <---INPUT FIELD---> 
                    "Add another" 

------------------------------------------------|

rest of the form

etc.

What do you think is the best strategy to make this, I already tried with jquery ajax putting the htmlfragment into a form but didn't work because form is initialized before and it can't see the added field.

thank you for your answer.

  [Opened] Adding multiple fields dinamically to a jForm

Reply #1 Posted by laurentj on 03/21/2014 16:13

Hi!

Sorry for the late, I did not see your message.

If the number of field is limited (let's say the user can have only 10 fields maximum for example), you can declare all these fields into the xml, and with few line of code of JS in your web page, you can hide them and show them like you do in any other website.

If the number of field is undetermined (no maximum field), or if the field type is undetermined (for instance the type of the next field depends of the value of the previous field), you should manage these fields by hand. It means that you should create yourself the HTML elements, check their value in the controller etc... However, you can use a jForm form for the form itself and other "static" fields. With other words : your "dynamic" fields are inside a jForm form but you have to manage them manually.

  [Opened] Adding multiple fields dinamically to a jForm

Reply #2 Posted by fluid on 04/23/2014 15:26

this is precisely what I did, with 10 fields :)

thanks F.

 
Page
  1. Adding multiple fields dinamically to a jForm