mirror of
https://github.com/getgrav/grav.git
synced 2026-07-10 20:13:28 +02:00
Fixed initial Flex Object state when creating a new objects in a form
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
* Fixed 404 error when you click to non-routable menu item with children: redirect to the first child instead
|
||||
* Fixed wrong `Pages::dispatch()` calls (with redirect) when we really meant to call `Pages::find()`
|
||||
* Fixed avatars not being displayed with flex users [#2431](https://github.com/getgrav/grav/issues/2431)
|
||||
* Fixed initial Flex Object state when creating a new objects in a form
|
||||
|
||||
# v1.7.0-beta.7
|
||||
## 08/30/2019
|
||||
|
||||
@@ -132,6 +132,7 @@ class FlexForm implements FlexFormInterface
|
||||
$data = $flash->getData();
|
||||
$includeOriginal = (bool)($this->getBlueprint()->form()['images']['original'] ?? null);
|
||||
|
||||
$this->object = $flash->getObject();
|
||||
$this->data = $data ? new Data($data, $this->getBlueprint()) : null;
|
||||
$this->files = $flash->getFilesByFields($includeOriginal);
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ class FlexFormFlash extends FormFlash
|
||||
$serialized['object'] = [
|
||||
'type' => $object->getFlexType(),
|
||||
'key' => $object->getKey() ?: null,
|
||||
'storage_key' => $object->exists() ? $object->getStorageKey() : null,
|
||||
'storage_key' => $object->getStorageKey(),
|
||||
'timestamp' => $object->getTimestamp(),
|
||||
'serialized' => $object->jsonSerialize()
|
||||
'serialized' => $object->prepareStorage()
|
||||
];
|
||||
}
|
||||
|
||||
@@ -51,9 +51,11 @@ class FlexFormFlash extends FormFlash
|
||||
{
|
||||
parent::init($data, $config);
|
||||
|
||||
/** @var FlexObjectInterface $object */
|
||||
$object = $config['object'];
|
||||
if (isset($data['object']['serialized']) && !$object->exists()) {
|
||||
$object->update($data['object']['serialized']);
|
||||
// TODO: update instead of create new.
|
||||
$object = $object->getFlexDirectory()->createObject($data['object']['serialized'], $data['object']['key']);
|
||||
}
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
Reference in New Issue
Block a user