FIX: field validation

This commit is contained in:
Will Rossiter 2014-04-22 16:46:57 -07:00
parent d8295c2a27
commit cbeb7a82e8

View File

@ -888,13 +888,19 @@ JS
foreach($this->Fields() as $field) { foreach($this->Fields() as $field) {
$messages[$field->Name] = $field->getErrorMessage()->HTML(); $messages[$field->Name] = $field->getErrorMessage()->HTML();
$formField = $field->getFormField();
if($field->Required && $field->CustomRules()->Count() == 0) { if($field->Required && $field->CustomRules()->Count() == 0) {
if( !isset($data[$field->Name]) || if(isset($data[$field->Name])) {
$formField->setValue($data[$field->Name]);
}
if(
!isset($data[$field->Name]) ||
!$data[$field->Name] || !$data[$field->Name] ||
!$field->getFormField()->validate($this->validator) !$formField->validate($form->getValidator())
) { ) {
$form->addErrorMessage($field->Name,$field->getErrorMessage()->HTML(),'bad'); $form->addErrorMessage($field->Name, $field->getErrorMessage(), 'bad');
} }
} }
} }