Forum

Thread tagged as: Question, Forms

Select multiple and perch_pages_navigation

Hi Drew/Rachel,

I had some code running on a page which has been working perfectly. In short, I am pulling in the perch_pages_navigation as a variable in to a select list in a Perch form and using a template to comma separate it.

Code on the page:

<?php
    PerchSystem::set_var('centreName', perch_pages_navigation(array('navgroup' => 'business-centres','template' => 'centres_select_options.html','levels' => 1,),true));
    perch_content_custom('Enquiry Form', array(
        'template'=>'general_enquiry_form.html',
    ));
?>

The select options template:

<perch:pages id="pageNavText" />

<perch:if exists="perch_item_first">
,
<perch:else />
    <perch:if exists="perch_item_last">
<perch:else />
    ,
    </perch:if>
</perch:if>

The select list that is on the form template:

<perch:input type="select" data-validation="required" data-validation-error-msg="Please select a business centre" data-validation-error-msg-container="#centre-select-error-dialog" options="Please Select|, <perch:content id="centreName" label="Centre name"/>" id="centreName" label="Centre" />

The client would like to allow multiple items to be selected. Am I right in thinking that Perch forms will not allow multiple select option as i tried it an it only passes in the first option?

Andy Knight

Andy Knight 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Perch forms currently don't have a model for a single field holding multiple values. It's something we may add in the future but it's not available now.

So would that apply to a checkbox group?

<perch:input type="checkbox" id="discount[]" value="A"  />
<perch:input type="checkbox" id="discount[]" value="B"  />
Drew McLellan

Drew McLellan 2638 points
Perch Support

You might get away with it if you don't have any validation errors.

No, doesn't seem to work, I don't get anything in the stored response.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, then it looks like the answer is currently no.