Permalink
Browse files

BUGFIX: avoid validating fields which have the potential to be hidden…

…. Fixes #5406 and #3
  • Loading branch information...
1 parent 2c9e68a commit 0978a1ebf80e6de72838571cc12771a598302b3a @wilr wilr committed Apr 14, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 code/model/UserDefinedForm.php
@@ -345,7 +345,7 @@ function Form() {
// get the required fields including the validation
$required = $this->getRequiredFields();
-
+
// generate the conditional logic
$this->generateConditionalJavascript();
@@ -445,8 +445,8 @@ function getRequiredFields() {
if($this->Fields()) {
foreach($this->Fields() as $field) {
$messages[$field->Name] = $field->getErrorMessage()->HTML();
-
- if($field->Required) {
+
+ if($field->Required && $field->CustomRules()->Count() == 0) {
$rules[$field->Name] = array_merge(array('required' => true), $field->getValidation());
$required->addRequiredField($field->Name);
}
@@ -462,6 +462,7 @@ function getRequiredFields() {
(function($) {
$(document).ready(function() {
$("#Form_Form").validate({
+ ignore: [':hidden'],
errorClass: "required",
messages:
$messages
@@ -632,13 +633,13 @@ function array2json($array) {
* @return Redirection
*/
function process($data, $form) {
-
Session::set("FormInfo.{$form->FormName()}.data",$data);
Session::clear("FormInfo.{$form->FormName()}.errors");
+
foreach($this->Fields() as $field) {
$messages[$field->Name] = $field->getErrorMessage()->HTML();
- if($field->Required){
+ if($field->Required && $field->CustomRules()->Count() == 0) {
if( !isset($data[$field->Name]) ||
!$data[$field->Name] ||
!$field->getFormField()->validate($this->validator)

0 comments on commit 0978a1e

Please sign in to comment.