Improve form helpers and add more hooks
This commit is contained in:
@@ -306,6 +306,48 @@ class FormHelper extends Base
|
||||
return $this->input('text', $name, $values, $errors, $attributes, $class.' form-numeric');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user