Skip to content

Instantly share code, notes, and snippets.

@nexeck
Created October 21, 2011 06:42
Show Gist options
  • Select an option

  • Save nexeck/1303249 to your computer and use it in GitHub Desktop.

Select an option

Save nexeck/1303249 to your computer and use it in GitHub Desktop.
formo view select with disabled attribute for readonly
<?php echo $open; ?>
<label<?php if ($id = $this->attr('id')) echo ' for="'.$id.'"'; ?>>
<?php echo $label; ?>
<span class="field">
<?php if ($this->editable() === TRUE): ?>
<?php echo $this->open(); ?>
<?php else: ?>
<?php $this->attr('disabled', 'disabled'); ?>
<?php echo $this->open(); ?>
<?php endif; ?>
<?php foreach ($this->_field->get('options') as $key => $value): ?>
<?php if (is_array($value)): ?>
<optgroup label="<?php echo $key?>">
<?php foreach ($value as $_key => $_value): ?>
<option<?php echo HTML::attributes($this->get_option_attr('select', $_key))?>><?php echo $this->option_label($_value)?></option>
<?php endforeach; ?>
</optgroup>
<?php else: ?>
<option<?php echo HTML::attributes($this->get_option_attr('select', $key))?>><?php echo $this->option_label($value)?></option>
<?php endif; ?>
<?php endforeach; ?>
<?php echo $this->close(); ?>
</span>
</label>
<?php echo $message; ?>
<?php echo $close; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment