Forum

Thread tagged as: Question, Forms

Repeaters in Forms

I am trying to have an editor-controlled form with a repeater in it. It is for a job application form, which will have a different number of questions and different questions for each job. I have the following code:

<perch:form id="contact" method="post" app="perch_forms">

    <div>
        <perch:label for="name">Name</perch:label>
        <perch:input type="text" id="name" required="true" label="Name" />
        <perch:error for="name" type="required">Please add your name</perch:error>
    </div>

    <div>
        <perch:label for="email">Email</perch:label>
        <perch:input type="email" id="email" required="true" label="Email" placeholder="you@company.com" />
        <perch:error for="email" type="required">Please add your email address</perch:error>
        <perch:error for="email" type="format">Please check your email address</perch:error>
    </div>

    <perch:repeater id="formfields" label="Application Form Fields">

         <div>
        <perch:label for="message"><perch:content id="question" type="textarea" label="Application Question" markdown="true" editor="markitup" imagewidth="640" imageheight="480" /></perch:label>
        <perch:input type="textarea" id="message" required="true" label="Message" />
        <perch:error for="message" type="required">Please answer this question</perch:error>
    </div>

    </perch:repeater>





    <div>
        <perch:input type="submit" id="submit" value="Send" />
    </div>

    <perch:success>
        <perch:content id="success" type="textarea" label="Thank you message" markdown="true" editor="markitup" />
    </perch:success>
</perch:form>

I am only getting the last repeater submitting and appearing in the forms app. I am not sure where I am going wrong. The fields are appearing on the site correctly.

Thanks

Mike

Mike Harrison

Mike Harrison 37 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Repeaters aren't supported within forms currently.

Cool cheers Drew.

Is there any way to have the same outcome e.g. a variable number of textareas, with the editor having control over the label for each one?

I have just tried Blocks with no joy!

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, forms need to be designed - there's no dynamic way to assemble a form.

Ok no worries, thanks!

Damian Drozdowicz

Damian Drozdowicz 0 points
Registered Developer

Hi Drew,

We are working on a little event registration app where a registration form should list out all the events available to sign-up for. According to our design - at the registration form, each active event is represented by a checkbox. It would be ideal to have a region where user could set checkboxes and labels himself.

Is there any workaround that comes to your mind that would allow to inject/manage additional inputs inside a form?

Cheers, Damian