Show select field for boolean parameters

This commit is contained in:
Eike Foken
2011-09-28 20:22:25 +02:00
parent 8c88f570ab
commit a65f4ed682
2 changed files with 23 additions and 1 deletions

View File

@@ -43,5 +43,19 @@ if (!function_exists('form_yesno')) {
}
}
if (!function_exists('form_boolean')) {
/**
* Shows a boolean selection.
*
* @param string $name
* @param mixed $selected
* @param string $extra
* @return string
*/
function form_boolean($name = '', $selected = array(), $extra = '') {
return form_dropdown($name, array('true' => _('True'), 'false' => _('False')), $selected, $extra);
}
}
/* End of file MY_form_helper.php */
/* Location: ./application/helpers/MY_form_helper.php */

View File

@@ -101,8 +101,16 @@
<tr>
<td><?=$param['readable'];?></td>
<td>
<input type="text" name="param-<?=$param['id'];?>" class="long text" value="<?=(!empty($_POST['param-' . $param['id']]) ? $this->input->post('param-' . $param['id']) : (isset($copy_params[$i]['value'])) ? $copy_params[$i]['value'] : $param['default_value']);?>" />
<?php
if ($param['type'] == 'boolean'):
?>
<?=form_boolean('param-'.$param['id'], (!empty($_POST['param-'.$param['id']]) ? $_POST('param-'.$param['id']) : (isset($copy_params[$i]['value'])) ? $copy_params[$i]['value'] : $param['default_value']), 'class="drop"')?>
<?php
else:
?>
<input type="text" name="param-<?=$param['id'];?>" class="long text" value="<?=(!empty($_POST['param-' . $param['id']]) ? $this->input->post('param-' . $param['id']) : (isset($copy_params[$i]['value'])) ? $copy_params[$i]['value'] : $param['default_value']);?>" />
<?php
endif;
if (!empty($param['description'])):
?>
<span class="form_info">