public static function select($name, $args = array()) { // attribs $args['name'] = $name; $args['id'] = $name; // value $value = \Meta\Core\Form::value($name, $args['value']); // label if ($args['label']) { echo \Meta\Core\Form::label($name, $args['label']); unset($args['label']); } // options $options = ''; if (!isset($args['required']) || isset($args['required']) && !$args['required']) { $options .= '<option value=""></option>' . "\n"; } if (is_array($args['options'])) { foreach ($args['options'] as $key => $val) { $selected = $value == $key ? ' selected="selected"' : ''; $options .= '<option ' . html_tag_values(array('value' => $key)) . $selected . '>' . $val . '</option>' . "\n"; } } // input <select> unset($args['options']); $html = '<select ' . html_tag_values($args) . '>' . $options . '</select>'; echo $html; }