FIX: validate required fields even with rules. (Fixes #116)

This commit is contained in:
Will Rossiter 2013-04-17 19:29:58 +12:00
parent 3b9419ab7e
commit a8ca0184c3

View File

@ -548,7 +548,7 @@ class UserDefinedForm_Controller extends Page_Controller {
foreach($this->Fields() as $field) { foreach($this->Fields() as $field) {
$messages[$field->Name] = $field->getErrorMessage()->HTML(); $messages[$field->Name] = $field->getErrorMessage()->HTML();
if($field->Required && $field->CustomRules()->Count() == 0) { if($field->Required) {
$rules[$field->Name] = array_merge(array('required' => true), $field->getValidation()); $rules[$field->Name] = array_merge(array('required' => true), $field->getValidation());
$required->addRequiredField($field->Name); $required->addRequiredField($field->Name);
} }
@ -570,7 +570,7 @@ class UserDefinedForm_Controller extends Page_Controller {
(function($) { (function($) {
$(document).ready(function() { $(document).ready(function() {
$("#Form_Form").validate({ $("#Form_Form").validate({
ignore: [':hidden'], ignore: ':hidden'`,
errorClass: "required", errorClass: "required",
errorPlacement: function(error, element) { errorPlacement: function(error, element) {
if(element.is(":radio")) { if(element.is(":radio")) {