mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX: validate required fields even with rules. (Fixes #116)
This commit is contained in:
parent
3b9419ab7e
commit
a8ca0184c3
@ -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")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user