BUGFIX: fixed rules with date fields and header fields. Appilied components of #4006

This commit is contained in:
Will Rossiter 2009-05-08 04:27:49 +00:00
parent cf39bbc71b
commit 10d5f41f24
2 changed files with 17 additions and 7 deletions

View File

@ -221,10 +221,15 @@ class UserDefinedForm_Controller extends Page_Controller {
if($fieldValidationOptions) { if($fieldValidationOptions) {
$fieldValidationRules[$field->Name] = $fieldValidationOptions; $fieldValidationRules[$field->Name] = $fieldValidationOptions;
} }
$fieldId = $field->Name;
if($field->ClassName == 'EditableFormHeading') {
$fieldId = 'Form_Form_'.$field->Name;
}
// Is this Field Show by Default // Is this Field Show by Default
if(!$field->ShowOnLoad()) { if(!$field->ShowOnLoad()) {
$defaults .= "$(\"#" . $field->Name . "\").hide();\n"; $defaults .= "$(\"#" . $fieldId . "\").hide();\n";
} }
// Check for field dependencies / default // Check for field dependencies / default
@ -254,8 +259,13 @@ class UserDefinedForm_Controller extends Page_Controller {
$view = (isset($dependency['Display']) && $dependency['Display'] == "Hide") ? "hide" : "show"; $view = (isset($dependency['Display']) && $dependency['Display'] == "Hide") ? "hide" : "show";
$opposite = ($view == "show") ? "hide" : "show"; $opposite = ($view == "show") ? "hide" : "show";
// what action do we need to keep track of // what action do we need to keep track of. Something nicer here maybe?
$Action = ($formFieldWatch->ClassName == "EditableTextField") ? "keyup" : "change"; // @todo encapulsation
$action = "change";
if($formFieldWatch->ClassName == "EditableTextField" || $formFieldWatch->ClassName == "EditableDateField") {
$action = "keyup";
}
// is this field a special option field // is this field a special option field
$checkboxField = false; $checkboxField = false;
@ -283,12 +293,12 @@ class UserDefinedForm_Controller extends Page_Controller {
break; break;
} }
// put it all together // put it all together
$CustomDisplayRules .= $fieldToWatch.".$Action(function() { $CustomDisplayRules .= $fieldToWatch.".$action(function() {
if(". $expression ." ) { if(". $expression ." ) {
$(\"#". $field->Name ."\").".$view."(); $(\"#". $fieldId ."\").".$view."();
} }
else { else {
$(\"#". $field->Name ."\").".$opposite."(); $(\"#". $fieldId ."\").".$opposite."();
} }
});"; });";
} }

View File

@ -24,7 +24,7 @@ class EditableFormHeading extends EditableFormField {
} }
function getFormField() { function getFormField() {
$labelField = new HeaderField('FormHeadingLabel',$this->Title, $this->getSetting('Level')); $labelField = new HeaderField($this->Name,$this->Title, $this->getSetting('Level'));
$labelField->addExtraClass('FormHeading'); $labelField->addExtraClass('FormHeading');
return $labelField; return $labelField;