Skip to content

Commit

Permalink
Merge pull request #1 from Gumster/new-input-helpers
Browse files Browse the repository at this point in the history
Add HTML5 input field helpers: url, time, date, email
Gumster authored Jun 29, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 120b1ef + be0020b commit b7385e2
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions core/helpers/mvc_form_helper.php
Original file line number Diff line number Diff line change
@@ -85,6 +85,62 @@ public function file_input($field_name, $options=array()) {
$html .= $this->after_input($field_name, $options);
return $html;
}

public function url_input($field_name, $options=array()) {
$defaults = array(
'id' => $this->input_id($field_name),
'name' => $this->input_name($field_name),
'type' => 'url'
);
$options = array_merge($defaults, $options);
$attributes_html = self::attributes_html($options, 'input');
$html = $this->before_input($field_name, $options);
$html .= '<input'.$attributes_html.' />';
$html .= $this->after_input($field_name, $options);
return $html;
}

public function email_input($field_name, $options=array()) {
$defaults = array(
'id' => $this->input_id($field_name),
'name' => $this->input_name($field_name),
'type' => 'email'
);
$options = array_merge($defaults, $options);
$attributes_html = self::attributes_html($options, 'input');
$html = $this->before_input($field_name, $options);
$html .= '<input'.$attributes_html.' />';
$html .= $this->after_input($field_name, $options);
return $html;
}

public function time_input($field_name, $options=array()) {
$defaults = array(
'id' => $this->input_id($field_name),
'name' => $this->input_name($field_name),
'type' => 'time'
);
$options = array_merge($defaults, $options);
$attributes_html = self::attributes_html($options, 'input');
$html = $this->before_input($field_name, $options);
$html .= '<input'.$attributes_html.' />';
$html .= $this->after_input($field_name, $options);
return $html;
}

public function date_input($field_name, $options=array()) {
$defaults = array(
'id' => $this->input_id($field_name),
'name' => $this->input_name($field_name),
'type' => 'date'
);
$options = array_merge($defaults, $options);
$attributes_html = self::attributes_html($options, 'input');
$html = $this->before_input($field_name, $options);
$html .= '<input'.$attributes_html.' />';
$html .= $this->after_input($field_name, $options);
return $html;
}

public function text_input($field_name, $options=array()) {
$defaults = array(

0 comments on commit b7385e2

Please sign in to comment.