Created
August 20, 2013 20:32
-
-
Save jbroadway/6286885 to your computer and use it in GitHub Desktop.
Dynamically populated multiple select in an Elefant CMS form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- apps/test/views/multiple.html --> | |
<form method="post" id="{{_form}}"> | |
<select name="type[]" multiple> | |
{% foreach options as val, label %} | |
<option value="{{val}}"{% if in_array ($data->val, $data->selected) %} selected{% end %}>{{label}}</option> | |
{% end %} | |
</select> | |
<input type="submit" value="Submit" /> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // apps/test/handlers/multiple.php | |
$form = new Form ('post', $this); | |
$form->data = array ( | |
'options' => array ( | |
'foo' => 'Foo', | |
'bar' => 'Bar', | |
'baz' => 'Baz' | |
), | |
'selected' => array ('bar', 'baz') | |
); | |
echo $form->handle (function ($form) { | |
info ($_POST); | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment