/** * Password::checkPassword() * * Check the value of this field with another password field * * @param \FormHandler\Field\Password $object * @return boolean true if the values are correct, false if not * @author Teye Heimans */ public function checkPassword($object) { // if the fields doesn't match if ($this->getValue() != $object->getValue()) { $this->setErrorMessage(\FormHandler\Language::get(15)); $this->setErrorState(true); return; } // when there is no value if ($this->getValue() == '' && !$this->form_object->edit) { $this->setErrorMessage(\FormHandler\Language::get(16)); $this->setErrorState(true); return; } elseif ($this->getValue() == '') { //in edit mode and value is empty return; } $validator = new Validator\Password(); // is the password not to short ? if (strlen($this->getValue()) < \FormHandler\Configuration::get('min_password_length')) { $this->setErrorMessage(sprintf(\FormHandler\Language::get(17), \FormHandler\Configuration::get('min_password_length'))); $this->setErrorState(true); return; } elseif (!$validator->validate($this->getValue())) { $this->setErrorMessage(\FormHandler\Language::get(18)); $this->setErrorState(true); return; } }
public function setValidator($validator = null) { if (count($this->getValidators()) === 0 && $validator instanceof FormHandler\Validator\FunctionCallable && is_array($validator->getCallable())) { $callable = $validator->getCallable(); //detect if it is an optional validator if ($callable[0] instanceof Validator && substr($callable[1], 0, 1) !== '_') { parent::setValidator(new \FormHandler\Validator\NotEmpty()); } } return parent::setValidator(FormHandler::parseValidator($validator, $this)); }
/** * FormHandler::passField() * * Create a password field * * @param string $title The title of the field * @param string $name The name of the field * @param string $validator The validator which should be used to validate the value of the field * @param int $size The size of the field * @param int $maxlength allowed max input of the field * @param string $extra CSS, Javascript or other which are inserted into the HTML tag * @return \FormHandler\Field\Password * @author Teye Heimans * @deprecated Use \FormHandler\Field\Password::set() instead */ public function passField($title, $name, $validator = null, $size = null, $maxlength = null, $extra = null) { $field = \FormHandler\Field\Password::set($this, $title, $name); return $field->setValidator(self::parseValidator($validator, $field))->setSize($size)->setMaxlength($maxlength)->setExtra($extra); }