Skip to content

Instantly share code, notes, and snippets.

@graphis
Created November 4, 2012 21:12
Show Gist options
  • Select an option

  • Save graphis/4013800 to your computer and use it in GitHub Desktop.

Select an option

Save graphis/4013800 to your computer and use it in GitHub Desktop.
<?php
class Kostache_Layout_Base extends Kostache_Layout
{
protected $_options_title_selected = null;
/**
* Returns an options list of titles.
*
* @return array
*/
public function options_title()
{
return array(
array(
'value' => 'Dr',
'option' => 'Dr',
'selected' => ($this->_options_title_selected == 'Dr'),
),
array(
'value' => 'Mr',
'option' => 'Mr',
'selected' => ($this->_options_title_selected == 'Mr'),
),
array(
'value' => 'Miss',
'option' => 'Miss',
'selected' => ($this->_options_title_selected == 'Miss'),
),
array(
'value' => 'Ms',
'option' => 'Ms',
'selected' => ($this->_options_title_selected == 'Ms'),
),
array(
'value' => 'Mrs',
'option' => 'Mrs',
'selected' => ($this->_options_title_selected == 'Mrs'),
),
);
}
}
<option></option>
{{#options_title}}
<option value="{{value}}" {{#selected}}selected="selected"{{/selected}}>{{option}}</option>
{{/options_title}}
<?php
class View_Signup extends View_Signup_Base
{
protected $_partials = array(
'title' => 'layouts/partials/person/title',
);
public function __construct($template = NULL, array $partials = NULL)
{
parent::__construct($template, $partials);
$this->_account = $this->_get_account();
}
protected function _get_account()
{
$session_account = Arr::get(Session::instance()->get('signup', array()), 'account');
// ...
$this->_options_title_selected = Arr::get($session_account, 'title');
// ...
}
}
<?php
class View_Signup_Base extends Kostache_Layout_Base
{
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment