Skip to content

Instantly share code, notes, and snippets.

@jbroadway
Created February 25, 2013 16:04
Show Gist options
  • Save jbroadway/5030841 to your computer and use it in GitHub Desktop.
Save jbroadway/5030841 to your computer and use it in GitHub Desktop.
Creating a yes/no select box form element in Elefant.
<!-- apps/demo/views/yesno.html -->
<form method="post" id="{{_form}}">
<p>
Yes/no:<br />
<select name="yesno">
<option value="yes"{% if yesno === 'yes' %} selected{% end %}>{"Yes"}</option>
<option value="no"{% if yesno === 'no' %} selected{% end %}>{"No"}</option>
</select>
</p>
<p><input type="submit" value="{"Submit"}" /></p>
</form>
<?php // apps/demo/handlers/yesno.php
$page->layout = 'admin';
$page->title = __ ('Yes/No Example');
$form = new Form ('post', $this);
// set the default to 'no'
$form->data = array ('yesno' => 'no');
echo $form->handle (function ($form) use ($page) {
$page->title = __ ('You Chose:');
printf ('<p>%s</p>', $_POST['yesno']);
});
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment