mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Fixes #8459
- Missing conditionals for optional constructor args - Missing calls to FieldList::setForm() - Missing guards around naive calls to Form::Fields()->foo()
This commit is contained in:
parent
2d1bd84c51
commit
0397c54b5a
@ -286,6 +286,9 @@ class Form extends ViewableData implements HasRequestHandler
|
|||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
$fields = $fields ? $fields : FieldList::create();
|
||||||
|
$actions = $actions ? $actions : FieldList::create();
|
||||||
|
|
||||||
$fields->setForm($this);
|
$fields->setForm($this);
|
||||||
$actions->setForm($this);
|
$actions->setForm($this);
|
||||||
|
|
||||||
@ -484,11 +487,13 @@ class Form extends ViewableData implements HasRequestHandler
|
|||||||
// Set message on either a field or the parent form
|
// Set message on either a field or the parent form
|
||||||
foreach ($result->getMessages() as $message) {
|
foreach ($result->getMessages() as $message) {
|
||||||
$fieldName = $message['fieldName'];
|
$fieldName = $message['fieldName'];
|
||||||
|
|
||||||
if ($fieldName) {
|
if ($fieldName) {
|
||||||
$owner = $this->fields->dataFieldByName($fieldName) ?: $this;
|
$owner = $this->fields->dataFieldByName($fieldName) ?: $this;
|
||||||
} else {
|
} else {
|
||||||
$owner = $this;
|
$owner = $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner->setMessage($message['message'], $message['messageType'], $message['messageCast']);
|
$owner->setMessage($message['message'], $message['messageType'], $message['messageCast']);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
@ -772,7 +777,9 @@ class Form extends ViewableData implements HasRequestHandler
|
|||||||
*/
|
*/
|
||||||
public function setFields($fields)
|
public function setFields($fields)
|
||||||
{
|
{
|
||||||
|
$fields->setForm($this);
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,7 +801,9 @@ class Form extends ViewableData implements HasRequestHandler
|
|||||||
*/
|
*/
|
||||||
public function setActions($actions)
|
public function setActions($actions)
|
||||||
{
|
{
|
||||||
|
$actions->setForm($this);
|
||||||
$this->actions = $actions;
|
$this->actions = $actions;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1405,8 +1414,9 @@ class Form extends ViewableData implements HasRequestHandler
|
|||||||
$submitted = true;
|
$submitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dont include fields without data
|
// Don't include fields without data
|
||||||
$dataFields = $this->Fields()->dataFields();
|
$dataFields = $this->Fields()->dataFields();
|
||||||
|
|
||||||
if (!$dataFields) {
|
if (!$dataFields) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user