1 Reply Latest reply on Mar 20, 2013 10:06 AM by rush_pawan

    Allow an author to add a dynamic number of datefields to a dialog

    Modulo216

      Hi All.  So I've run into a problem that I'm not sure how to even approach.  I'm very familiar with creating dialogs for my authors, but what I need to do is allow them dynamically Add and Remove a number of datefields.  I add a datefield now to my dialog.xml like so:

       

      <startDate

      jcr:primaryType="cq:Widget"

      fieldLabel="Start Date"

      name="./startDate"

      xtype="datefield"/>

       

      What I'd like to do is have a Add and Remove button / link that will add or remove a new datefield to the dialog.  From there I also need to figure out how to handle these items on the server side.

       

      If someone could point me in the right direction that would be very helpful.

        • 1. Re: Allow an author to add a dynamic number of datefields to a dialog
          rush_pawan Level 4

          Hi,

           

          Instead of using datefield widget directly use multified widget and configure it with datefield as below

           

                         <dates

                              jcr:primaryType="cq:Widget"

                              fieldLabel="Dates"

                              name="./dates"

                              xtype="multifield">

                              <fieldConfig

                                  jcr:primaryType="nt:unstructured"

                                  xtype="datefield"/>

                          </dates>

           

          So here first create a node with xtype as "multifield" and then inside that node create another nt:unstructured node and configure it using xtype "datefield".

           

          You can access this field similar to how you access multifield in normal case (as String[]).

           

          Let me know if you need more information or faced any issue during implementation.

           

          Thanks,

          Pawan