Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

[Admin] Added Route Parameters to MenuNodeAdmin #109

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
13 changes: 12 additions & 1 deletion src/Admin/Menu/MenuNodeAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Sonata\DoctrinePHPCRAdminBundle\Form\Type\ChoiceFieldMaskType;
use Knp\Menu\ItemInterface as MenuItemInterface;
use Doctrine\Common\Util\ClassUtils;
use Burgov\Bundle\KeyValueFormBundle\Form\Type\KeyValueType;

class MenuNodeAdmin extends AbstractMenuNodeAdmin
{
Expand Down Expand Up @@ -69,14 +70,24 @@ protected function configureFormFields(FormMapper $formMapper)
'content' => 'content',
),
'map' => array(
'route' => array('link'),
'route' => array('link','routeParameters'),
'uri' => array('link'),
'content' => array('content', TreeSelectType::class),
),
'placeholder' => 'auto',
'required' => false,
))
->add('link', TextType::class, array('required' => false, 'mapped' => false))
->add('routeParameters', KeyValueType::class, array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently the key-value bundle is an optional dependency. even if we would make it a hard dependency, the user still needs to load the bundle in the kernel.

i think we should have an options array in the constructor to choose whether route parameters should be editable. then the DI extension can check whether the keyvaluebundle is loaded and complain if its not. the seo bundle form type does this, see the form and the DI extension and configuration

can you please add the configuration for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BadPixxel any chances to get this one ready. Or shall we finish it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thansk for you feedback. I'll do it, just need time.
Question... shall we filter only route parameters or whole route configuration options?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would only make the route parameters optional. the rest works without the key-value bundle

'value_type' => TextType::class,
'required' => false,
'entry_options' => array(
'value_type' => TextType::class,
'label' => false,
'attr' => array('style' => 'clear:both'),
),
"label" => "form.label_options"
))
->add(
'content',
TreeSelectType::class,
Expand Down