Skip to content

Instantly share code, notes, and snippets.

@jbroadway
Created August 20, 2013 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbroadway/6286438 to your computer and use it in GitHub Desktop.
Save jbroadway/6286438 to your computer and use it in GitHub Desktop.
Dynamically populated select box in an Elefant CMS template.
<!-- apps/test/views/select.html -->
<select name="type">
{% foreach options as val, label %}
<option value="{{val}}"{% if selected == $data->val %} selected{% end %}>{{label}}</option>
{% end %}
</select>
<?php // apps/test/handlers/select.php
echo $tpl->render (
'test/select',
array (
'options' => array (
'foo' => 'Foo',
'bar' => 'Bar',
'baz' => 'Baz'
),
'selected' => 'bar'
)
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment