summaryrefslogtreecommitdiff
path: root/app/Helper/FormHelper.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-08-13 17:49:27 -0400
committerFrederic Guillot <fred@kanboard.net>2016-08-13 17:49:27 -0400
commitffe61abc6910670c5c2c243eb82d9f5851f06c6b (patch)
tree0a1833f8a7f22ac239f8914f2e870a881e630e41 /app/Helper/FormHelper.php
parent4ffaba2ba0dd6b5810adea1916080c3b645f3d29 (diff)
Improve form helpers and add more hooks
Diffstat (limited to 'app/Helper/FormHelper.php')
-rw-r--r--app/Helper/FormHelper.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/app/Helper/FormHelper.php b/app/Helper/FormHelper.php
index c2ea1d72..0bb94d39 100644
--- a/app/Helper/FormHelper.php
+++ b/app/Helper/FormHelper.php
@@ -307,6 +307,48 @@ class FormHelper extends Base
}
/**
+ * Date field
+ *
+ * @access public
+ * @param string $label
+ * @param string $name
+ * @param array $values
+ * @param array $errors
+ * @param array $attributes
+ * @return string
+ */
+ public function date($label, $name, array $values, array $errors = array(), array $attributes = array())
+ {
+ $userFormat = $this->dateParser->getUserDateFormat();
+ $values = $this->dateParser->format($values, array($name), $userFormat);
+ $attributes = array_merge(array('placeholder="'.date($userFormat).'"'), $attributes);
+
+ return $this->helper->form->label($label, $name) .
+ $this->helper->form->text($name, $values, $errors, $attributes, 'form-date');
+ }
+
+ /**
+ * Datetime field
+ *
+ * @access public
+ * @param string $label
+ * @param string $name
+ * @param array $values
+ * @param array $errors
+ * @param array $attributes
+ * @return string
+ */
+ public function datetime($label, $name, array $values, array $errors = array(), array $attributes = array())
+ {
+ $userFormat = $this->dateParser->getUserDateTimeFormat();
+ $values = $this->dateParser->format($values, array($name), $userFormat);
+ $attributes = array_merge(array('placeholder="'.date($userFormat).'"'), $attributes);
+
+ return $this->helper->form->label($label, $name) .
+ $this->helper->form->text($name, $values, $errors, $attributes, 'form-datetime');
+ }
+
+ /**
* Display the form error class
*
* @access private