From be0020b36816f0eab6d98cdcb9487599b902ef54 Mon Sep 17 00:00:00 2001 From: Gumster Date: Sat, 29 Jun 2019 11:51:52 +0100 Subject: [PATCH] Add input field helpers: url, time, date, email --- core/helpers/mvc_form_helper.php | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/core/helpers/mvc_form_helper.php b/core/helpers/mvc_form_helper.php index ffff7f0..eb1fba2 100644 --- a/core/helpers/mvc_form_helper.php +++ b/core/helpers/mvc_form_helper.php @@ -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 .= ''; + $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 .= ''; + $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 .= ''; + $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 .= ''; + $html .= $this->after_input($field_name, $options); + return $html; + } public function text_input($field_name, $options=array()) { $defaults = array(