diff options
Diffstat (limited to 'platform/www/lib/plugins/bureaucracy/helper/fieldemail.php')
-rw-r--r-- | platform/www/lib/plugins/bureaucracy/helper/fieldemail.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/platform/www/lib/plugins/bureaucracy/helper/fieldemail.php b/platform/www/lib/plugins/bureaucracy/helper/fieldemail.php new file mode 100644 index 0000000..7857bd7 --- /dev/null +++ b/platform/www/lib/plugins/bureaucracy/helper/fieldemail.php @@ -0,0 +1,30 @@ +<?php +/** + * Class helper_plugin_bureaucracy_fieldemail + * + * Creates a single line input field where the input is validated to be a valid email address + */ +class helper_plugin_bureaucracy_fieldemail extends helper_plugin_bureaucracy_fieldtextbox { + + /** + * Arguments: + * - cmd + * - label + * - @@ (optional) + * - ^ (optional) + */ + + /** + * Validate field value + * + * @throws Exception when empty or not valid email address + */ + function _validate() { + parent::_validate(); + + $value = $this->getParam('value'); + if(!is_null($value) && $value !== '@MAIL@' && !mail_isvalid($value)){ + throw new Exception(sprintf($this->getLang('e_email'),hsc($this->getParam('display')))); + } + } +} |