/** * @todo Document this method * * @param string object_name Name of an ActiveRecord subclass * @param string attribute_name Name of an attribute of $object_name * @param string[] options * @uses attribute_name * @uses column_type() * @uses error_wrapping() * @uses object_name * @uses DateHelper::to_date_select_tag() * @uses FormHelper::to_boolean_select_tag() * @uses FormHelper::to_input_field_tag() * @uses FormHelper::to_text_area_tag() * @uses to_datetime_select_tag() * @uses object() */ function to_tag($object_name, $attribute_name, $options = array()) { $this->object_name = $object_name; $this->attribute_name = $attribute_name; $form = new FormHelper($object_name, $attribute_name); switch ($this->column_type()) { case 'string': case 'varchar': case 'varchar2': $field_type = preg_match("/password/i", $this->attribute_name) ? "password" : "text"; $results = $form->to_input_field_tag($field_type, $options); break; case 'text': case 'blob': $results = $form->to_text_area_tag($options); break; case 'integer': case 'int': case 'number': case 'float': case 'real': $results = $form->to_input_field_tag("text", $options); break; case 'date': $form = new DateHelper($object_name, $attribute_name); $results = $form->to_date_select_tag($options); break; case 'datetime': case 'timestamp': $results = $this->to_datetime_select_tag($options); break; case 'boolean': case 'bool': $results = $form->to_boolean_select_tag($options); break; } if (count($this->object()->errors)) { $results = $this->error_wrapping($results, $this->object()->errors[$this->attribute_name]); } return $results; }