mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUG Fix double encoding of validation errors
This commit is contained in:
parent
ab79e5cd11
commit
0a8c7636d7
@ -555,40 +555,14 @@ JS
|
|||||||
/**
|
/**
|
||||||
* Process the form that is submitted through the site
|
* Process the form that is submitted through the site
|
||||||
*
|
*
|
||||||
|
* {@see UserForm::validate()} for validation step prior to processing
|
||||||
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @param Form $form
|
* @param Form $form
|
||||||
*
|
*
|
||||||
* @return Redirection
|
* @return Redirection
|
||||||
*/
|
*/
|
||||||
public function process($data, $form) {
|
public 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();
|
|
||||||
$formField = $field->getFormField();
|
|
||||||
|
|
||||||
if($field->Required && $field->DisplayRules()->Count() == 0) {
|
|
||||||
if(isset($data[$field->Name])) {
|
|
||||||
$formField->setValue($data[$field->Name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(
|
|
||||||
!isset($data[$field->Name]) ||
|
|
||||||
!$data[$field->Name] ||
|
|
||||||
!$formField->validate($form->getValidator())
|
|
||||||
) {
|
|
||||||
$form->addErrorMessage($field->Name, $field->getErrorMessage(), 'bad');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Session::get("FormInfo.{$form->FormName()}.errors")){
|
|
||||||
Controller::curr()->redirectBack();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$submittedForm = Object::create('SubmittedForm');
|
$submittedForm = Object::create('SubmittedForm');
|
||||||
$submittedForm->SubmittedByID = ($id = Member::currentUserID()) ? $id : 0;
|
$submittedForm->SubmittedByID = ($id = Member::currentUserID()) ? $id : 0;
|
||||||
$submittedForm->ParentID = $this->ID;
|
$submittedForm->ParentID = $this->ID;
|
||||||
@ -598,9 +572,7 @@ JS
|
|||||||
$submittedForm->write();
|
$submittedForm->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = array();
|
|
||||||
$attachments = array();
|
$attachments = array();
|
||||||
|
|
||||||
$submittedFields = new ArrayList();
|
$submittedFields = new ArrayList();
|
||||||
|
|
||||||
foreach($this->Fields() as $field) {
|
foreach($this->Fields() as $field) {
|
||||||
|
@ -675,7 +675,7 @@ class EditableFormField extends DataObject {
|
|||||||
!$data[$this->Name] ||
|
!$data[$this->Name] ||
|
||||||
!$formField->validate($form->getValidator())
|
!$formField->validate($form->getValidator())
|
||||||
) {
|
) {
|
||||||
$form->addErrorMessage($this->Name, $this->getErrorMessage(), 'bad');
|
$form->addErrorMessage($this->Name, $this->getErrorMessage()->HTML(), 'bad', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user