Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/doctrine-mapping/model/MenuItem.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<field name="type" column="item_type" type="smallint" nullable="false"/>

<field name="text" column="item_text" type="json" nullable="false"/>
<field name="text" column="item_text" type="sfs_translation" nullable="false"/>

<field name="options" column="options" type="json" nullable="true"/>

Expand Down
8 changes: 4 additions & 4 deletions src/Form/Admin/Menu/MenuItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Softspring\CmsBundle\Form\Admin\Menu;

use Doctrine\ORM\EntityManagerInterface;
use Softspring\CmsBundle\Form\Type\SymfonyRouteType;
use Softspring\CmsBundle\Form\Type\TranslatableType;
use Softspring\CmsBundle\Form\Type\LinkType;
use Softspring\CmsBundle\Form\Type\TranslationType;
use Softspring\CmsBundle\Manager\MenuItemManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down Expand Up @@ -33,11 +33,11 @@ public function configureOptions(OptionsResolver $resolver): void

public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('text', TranslatableType::class, [
$builder->add('text', TranslationType::class, [
'constraints' => new NotBlank(),
]);

$builder->add('symfonyRoute', SymfonyRouteType::class, [
$builder->add('symfonyRoute', LinkType::class, [
'required' => false,
]);
}
Expand Down
7 changes: 4 additions & 3 deletions src/Model/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Softspring\TranslatableBundle\Model\Translation;

abstract class MenuItem implements MenuItemInterface
{
protected ?MenuInterface $menu = null;

protected ?int $type = MenuItemInterface::TYPE_ROUTE;

protected ?array $text = null;
protected array|Translation|null $text = null;

protected ?array $options = null;

Expand Down Expand Up @@ -49,12 +50,12 @@ public function setType(?int $type): void
$this->type = $type;
}

public function getText(): ?array
public function getText(): array|Translation|null
{
return $this->text;
}

public function setText(?array $text): void
public function setText(array|Translation|null $text): void
{
$this->text = $text;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Model/MenuItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Softspring\CmsBundle\Model;

use Doctrine\Common\Collections\Collection;
use Softspring\TranslatableBundle\Model\Translation;

interface MenuItemInterface
{
Expand All @@ -20,9 +21,9 @@ public function setType(?int $type): void;

public function getType(): ?int;

public function setText(?array $text): void;
public function setText(array|Translation|null $text): void;

public function getText(): ?array;
public function getText(): array|Translation|null;

public function getSymfonyRoute(): ?array;

Expand Down
5 changes: 3 additions & 2 deletions templates/forms/menus_theme.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{% endblock menu_item_collection_widget %}

{% block menu_item_row %}
<div data-collection="node" {{ block('widget_container_attributes') }} data-collection-index="{{ form.vars.name }}" data-full-name="{{ form.vars.full_name }}">
<div class="mb-2" data-collection="node" {{ block('widget_container_attributes') }} data-collection-index="{{ form.vars.name }}" data-full-name="{{ form.vars.full_name }}">
<div class="row my-3 bg-light border-bottom p-3 g-0">
<div class="col-sm-1"><span data-collection="node-index" class="btn btn-primary">{{ form.vars.name }}</span></div>
<div class="col-sm-8">{{ form_widget(form) }}{{ form_errors(form) }}</div>
Expand All @@ -67,7 +67,8 @@
<div class="row {{ not form.parent.vars.valid ? 'show-invalid' }}">
<div class="col-sm-2">{{ form_label(form.text) }}</div>
<div class="col-sm">{{ form_widget(form.text) }}{{ form_errors(form.text) }}</div>
<div class="col-12">{{ form_label(form.symfonyRoute) }}</div>
{# <div class="col-12">{{ form_label(form.symfonyRoute) }}</div>#}
<div class="col-12">{{ form_widget(form.symfonyRoute) }}</div>
{{ form_rest(form) }}
</div>
{% endblock menu_item_widget %}