<commit_before><?php

class MvcFormHelper extends MvcHelper {
	
	public function create($model_name, $options=array()) {
		$defaults = array(
			'action' => $this->controller->action,
			'controller' => MvcInflector::tableize($model_name)
		);
		$options = array_merge($defaults, $options);
		$this->model_name = $model_name;
		$this->object = MvcObjectRegistry::get_object($model_name);
		$this->model = MvcModelRegistry::get_model($model_name);
		$this->schema = $this->model->schema;
		$object_id = !empty($this->object) && !empty($this->object->__id) ? $this->object->__id : null;
		$router_options = array('controller' => $options['controller'], 'action' => $options['action']);
		if ($object_id) {
			$router_options['id'] = $object_id;
		}
		$html = '<form action="'.MvcRouter::admin_url($router_options).'" method="post">';
		if ($object_id) {
			$html .= '<input type="hidden" name="'.$this->input_name('id').'" value="'.$object_id.'" />';
		}
		return $html;
	}
	
	public function end($label='Submit') {
		$html = '<div><input type="submit" value="'.$this->esc_attr($label).'" /></div>';
		$html .= '</form>';
		return $html;
	}
	
	// Generalized method that chooses the appropriate input type based on the SQL type of the field
	public function input($field_name, $options=array()) {
		if (!empty($this->schema[$field_name])) {
			$schema = $this->schema[$field_name];
			$type = $this->get_type_from_sql_schema($schema);
			$defaults = array(
				'type' => $type,
				'label' => MvcInflector::titleize($schema['field']),
				'value' => empty($this->object->$field_name) ? '' : $this->object->$field_name
			);
			if ($type == 'checkbox') {
				unset($defaults['value']);<commit_msg>Adding an id attribute to the hidden input in MvcFormHelper::create()<commit_after><?php

class MvcFormHelper extends MvcHelper {
	
	public function create($model_name, $options=array()) {
		$defaults = array(
			'action' => $this->controller->action,
			'controller' => MvcInflector::tableize($model_name)
		);
		$options = array_merge($defaults, $options);
		$this->model_name = $model_name;
		$this->object = MvcObjectRegistry::get_object($model_name);
		$this->model = MvcModelRegistry::get_model($model_name);
		$this->schema = $this->model->schema;
		$object_id = !empty($this->object) && !empty($this->object->__id) ? $this->object->__id : null;
		$router_options = array('controller' => $options['controller'], 'action' => $options['action']);
		if ($object_id) {
			$router_options['id'] = $object_id;
		}
		$html = '<form action="'.MvcRouter::admin_url($router_options).'" method="post">';
		if ($object_id) {
			$html .= '<input type="hidden" id="'.$this->input_id('hidden_id').'" name="'.$this->input_name('id').'" value="'.$object_id.'" />';
		}
		return $html;
	}
	
	public function end($label='Submit') {
		$html = '<div><input type="submit" value="'.$this->esc_attr($label).'" /></div>';
		$html .= '</form>';
		return $html;
	}
	
	// Generalized method that chooses the appropriate input type based on the SQL type of the field
	public function input($field_name, $options=array()) {
		if (!empty($this->schema[$field_name])) {
			$schema = $this->schema[$field_name];
			$type = $this->get_type_from_sql_schema($schema);
			$defaults = array(
				'type' => $type,
				'label' => MvcInflector::titleize($schema['field']),
				'value' => empty($this->object->$field_name) ? '' : $this->object->$field_name
			);
			if ($type == 'checkbox') {
				unset($defaults['value']);
{'fraction_non_alphanumeric': 0.21309592188397472, 'fraction_numerical': 0.0, 'mean_word_length': 5.046875, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4310367', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1156, 'n_words': 217}