public function validate(CM_Frontend_Environment $environment, $userInput) { $userInput = parent::validate($environment, $userInput); if (false === filter_var($userInput, FILTER_VALIDATE_URL)) { throw new CM_Exception_FormFieldValidation(new CM_I18n_Phrase('Invalid url')); } return $userInput; }
public function validate(CM_Frontend_Environment $environment, $userInput) { $userInput = parent::validate($environment, $userInput); if (!is_numeric($userInput)) { throw new CM_Exception_FormFieldValidation(new CM_I18n_Phrase('Not numeric')); } return (double) $userInput; }
public function validate(CM_Frontend_Environment $environment, $userInput) { $userInput = parent::validate($environment, $userInput); $emailVerification = $this->_getEmailVerification(); if (!$emailVerification->isValid($userInput)) { throw new CM_Exception_FormFieldValidation('Invalid email address'); } return $userInput; }
function testArrayInputInvalidCharsRemoval() { $invalidInputs = array(chr(240), chr(192), chr(200) . chr(210), 'something' . chr(244)); $field = new CM_FormField_Text(['name' => 'foo']); foreach ($invalidInputs as $input) { $filtered = $field->filterInput($input); $this->assertNotSame($filtered, $input); } }
public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse) { parent::prepare($renderParams, $environment, $viewResponse); $viewResponse->set('timeZone', $this->_getTimeZone($environment)); }
protected function _initialize() { $this->_params->set('lengthMin', 4); $this->_params->set('lengthMax', 100); parent::_initialize(); }
protected function _initialize() { $this->_setMinMaxOptions(); parent::_initialize(); }