|
|
@ -2,10 +2,13 @@ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Objects of this class can be used to create/manipulate/validate user input. |
|
|
|
* Class FormValidator |
|
|
|
|
|
|
|
* create/manipulate/validate user input. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class FormValidator extends HTML_QuickForm |
|
|
|
class FormValidator extends HTML_QuickForm |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
const LAYOUT_HORIZONTAL = 'horizontal'; |
|
|
|
|
|
|
|
const LAYOUT_INLINE = 'inline'; |
|
|
|
public $with_progress_bar = false; |
|
|
|
public $with_progress_bar = false; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -15,6 +18,7 @@ class FormValidator extends HTML_QuickForm |
|
|
|
* @param string $action (optional Action (default is $PHP_SELF) |
|
|
|
* @param string $action (optional Action (default is $PHP_SELF) |
|
|
|
* @param string $target (optional Form's target defaults to '_self' |
|
|
|
* @param string $target (optional Form's target defaults to '_self' |
|
|
|
* @param mixed $attributes (optional) Extra attributes for <form> tag |
|
|
|
* @param mixed $attributes (optional) Extra attributes for <form> tag |
|
|
|
|
|
|
|
* @param string $layout |
|
|
|
* @param bool $trackSubmit (optional) Whether to track if the form was |
|
|
|
* @param bool $trackSubmit (optional) Whether to track if the form was |
|
|
|
* submitted by adding a special hidden field (default = true) |
|
|
|
* submitted by adding a special hidden field (default = true) |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -24,6 +28,7 @@ class FormValidator extends HTML_QuickForm |
|
|
|
$action = '', |
|
|
|
$action = '', |
|
|
|
$target = '', |
|
|
|
$target = '', |
|
|
|
$attributes = null, |
|
|
|
$attributes = null, |
|
|
|
|
|
|
|
$layout = self::LAYOUT_HORIZONTAL, |
|
|
|
$trackSubmit = true |
|
|
|
$trackSubmit = true |
|
|
|
) { |
|
|
|
) { |
|
|
|
// Default form class. |
|
|
|
// Default form class. |
|
|
@ -31,6 +36,19 @@ class FormValidator extends HTML_QuickForm |
|
|
|
$attributes['class'] = 'form-horizontal'; |
|
|
|
$attributes['class'] = 'form-horizontal'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($attributes['class']) && strpos($attributes['class'], 'form-search') !== false) { |
|
|
|
|
|
|
|
$layout = 'inline'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($layout) { |
|
|
|
|
|
|
|
case self::LAYOUT_HORIZONTAL: |
|
|
|
|
|
|
|
$attributes['class'] = 'form-horizontal'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case self::LAYOUT_INLINE: |
|
|
|
|
|
|
|
$attributes['class'] = 'form-inline'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parent::__construct($name, $method, $action, $target, $attributes, $trackSubmit); |
|
|
|
parent::__construct($name, $method, $action, $target, $attributes, $trackSubmit); |
|
|
|
|
|
|
|
|
|
|
|
// Load some custom elements and rules |
|
|
|
// Load some custom elements and rules |
|
|
@ -298,7 +316,7 @@ EOT; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Shortcut to import button |
|
|
|
* Shortcut to export button |
|
|
|
* @param string $label |
|
|
|
* @param string $label |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function addButtonExport($label, $name = 'submit') |
|
|
|
public function addButtonExport($label, $name = 'submit') |
|
|
@ -306,6 +324,17 @@ EOT; |
|
|
|
return $this->addButton($name, $label, 'check', 'primary'); |
|
|
|
return $this->addButton($name, $label, 'check', 'primary'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Shortcut to filter button |
|
|
|
|
|
|
|
* @param string $label |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function addButtonFilter($label, $name = 'submit') |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->addButton($name, $label, 'filter', 'primary'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param string $name |
|
|
|
* @param string $name |
|
|
|
* @param string $label |
|
|
|
* @param string $label |
|
|
|