mirror of
https://github.com/getgrav/grav.git
synced 2026-07-05 04:17:25 +02:00
Flex form: Allow custom form layouts in admin, too (page raw mode)
This commit is contained in:
@@ -13,7 +13,6 @@ use Grav\Common\Data\Blueprint;
|
||||
use Grav\Common\Data\Data;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Twig\Twig;
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Framework\Flex\Interfaces\FlexFormInterface;
|
||||
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
|
||||
use Grav\Framework\Form\Traits\FormTrait;
|
||||
@@ -60,9 +59,21 @@ class FlexForm implements FlexFormInterface
|
||||
}
|
||||
$this->setObject($object);
|
||||
$this->setId($this->getName());
|
||||
$this->setUniqueId(md5($uniqueId));
|
||||
$this->setUniqueId(md5($name . $uniqueId));
|
||||
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
$this->messages = [];
|
||||
$this->submitted = false;
|
||||
$this->data = null;
|
||||
$this->files = [];
|
||||
$this->unsetFlash();
|
||||
|
||||
$flash = $this->getFlash();
|
||||
if ($flash->exists()) {
|
||||
@@ -71,10 +82,9 @@ class FlexForm implements FlexFormInterface
|
||||
|
||||
$this->data = $data ? new Data($data, $this->getBlueprint()) : null;
|
||||
$this->files = $flash->getFilesByFields($includeOriginal);
|
||||
} else {
|
||||
$this->data = null;
|
||||
$this->files = [];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +95,7 @@ class FlexForm implements FlexFormInterface
|
||||
$object = $this->getObject();
|
||||
$name = $this->name ?: 'object';
|
||||
|
||||
return "flex-{$object->getFlexType()}-{$name}";
|
||||
return "flex-{$object->getFlexType()}--{$name}";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +192,7 @@ class FlexForm implements FlexFormInterface
|
||||
{
|
||||
if (null === $this->blueprint) {
|
||||
try {
|
||||
$blueprint = $this->getObject()->getBlueprint(Utils::isAdminPlugin() ? '' : $this->name);
|
||||
$blueprint = $this->getObject()->getBlueprint($this->name);
|
||||
if ($this->form) {
|
||||
// We have field overrides available.
|
||||
$blueprint->extend(['form' => $this->form], true);
|
||||
|
||||
@@ -394,7 +394,7 @@ class FolderStorage extends AbstractFilesystemStorage
|
||||
$list = [];
|
||||
/** @var \SplFileInfo $info */
|
||||
foreach ($iterator as $filename => $info) {
|
||||
if (!$info->isDir()) {
|
||||
if (!$info->isDir() || strpos($info->getFilename(), '.') === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user