mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merged [47028]: Encountered a problem with Form::formHtmlContent not always including javascript validation, so added a call to includeJavascriptValidation on the validator in Form::formHtmlContent. Also modified Validator to notify the form that the client-side validation JavaScript has already been included. This way it isn't included twice.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60311 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
11e4621f66
commit
2d9c833de5
@ -63,6 +63,14 @@ class Form extends RequestHandlingData {
|
||||
protected $messageType;
|
||||
|
||||
protected $security = true;
|
||||
|
||||
/**
|
||||
* HACK This is a temporary hack to allow multiple calls to includeJavascriptValidation on
|
||||
* the validator (if one is present).
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $jsValidationIncluded = false;
|
||||
|
||||
/**
|
||||
* Create a new form, with the given fields an action buttons.
|
||||
@ -412,7 +420,7 @@ class Form extends RequestHandlingData {
|
||||
// Forms shouldn't be cached, cos their error messages won't be shown
|
||||
HTTP::set_cache_age(0);
|
||||
|
||||
if($this->validator) $this->validator->includeJavascriptValidation();
|
||||
if($this->validator && !$this->jsValidationIncluded) $this->validator->includeJavascriptValidation();
|
||||
if($this->target) $target = " target=\"".$this->target."\"";
|
||||
else $target = "";
|
||||
|
||||
@ -832,6 +840,10 @@ class Form extends RequestHandlingData {
|
||||
* the attributes of the form. These fields can be used to send the form to Ajax.
|
||||
*/
|
||||
function formHtmlContent() {
|
||||
// Call FormAttributes to force inclusion of custom client-side validation of fields
|
||||
// because it won't be included by the template
|
||||
if($this->validator && !$this->jsValidationIncluded) $this->validator->includeJavascriptValidation();
|
||||
|
||||
$this->IncludeFormTag = false;
|
||||
$content = $this->forTemplate();
|
||||
$this->IncludeFormTag = true;
|
||||
|
@ -122,6 +122,8 @@ Behaviour.apply('#$formID');
|
||||
JS;
|
||||
|
||||
Requirements::customScript($js);
|
||||
// HACK Notify the form that the validators client-side validation code has already been included
|
||||
if($this->form) $this->form->jsValidationIncluded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user