public function field($type, $name, $attributes = null) { if (!array_key_exists($name, $this->fields)) { $this->fields[$name] = null; } switch ($type) { case 'input': return HTML::input($name, $this->fields[$name], $attributes); case 'hidden': return HTML::hidden($name, $this->fields[$name], $attributes); case 'textarea': return HTML::textarea($name, $this->fields[$name], $attributes); case 'checkbox': return HTML::checkbox($name, 1, (bool) $this->fields[$name], $attributes); case 'password': return HTML::password($name, $this->fields[$name], $attributes); case 'select': if ($attributes and isset($attributes['multiple']) and $attributes['multiple'] !== false) { return HTML::select($name . '[]', $this->select_data[$name], $this->fields[$name], $attributes); } return HTML::select($name, $this->select_data[$name], $this->fields[$name], $attributes); case 'file': return HTML::file($name, $attributes); } }