Closed benglass closed 10 years ago
https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle/issues/92
Looks like perhaps we can just use this for the time being so that people can edit route parameters for menu nodes of link type route.
Just tested the use of a collection field for this and it does not allow editing of the keys which would be a requirement in this case so this would require a custom form type most likely.
related to #81
so far we helped ourselves by explicitly having an immutable array in the form, see for example https://github.com/symfony-cmf/RoutingBundle/blob/master/Admin/RouteAdmin.php#L87 . for your usecase you could create a specific menu node that has such fields, that is less flexible but more user friendly for your editors.
but indeed, having a mutable array (hashmap) would be quite cool.
The associative array form field would definitely be a valuable addition to Sonata I think /cc @rande
Immutable array type already exists . Name can be confusing ... Le 4 oct. 2013 09:03, "dantleech" notifications@github.com a écrit :
The associative array form field would definitely be a valuable addition to Sonata I think /cc @rande https://github.com/rande
— Reply to this email directly or view it on GitHubhttps://github.com/symfony-cmf/MenuBundle/issues/143#issuecomment-25679848 .
@rande: we know and use the immutable array. but we would love a mutable array where we can add named key-value pairs to. or are you saying immutable array type is actually mutable in the sense of adding/removing entries?
@dbu looking at the code for the ImmutableType it doesnt extend collection just the AbstractType from symfony so i dont think it has any capability for add/remove.
Looks like a separate type is needed (mutable_array perhaps). I don't think this could extend ImmutableArrayType as that is not a collection type so would not facilitate add/remove.
okay. well maybe the ImmutableType could be refactored to become a special case of the MutableType? anyway, we should look into basic form support for this, it should not necessarily be sonata specific. maybe it could go into the DoctrinePHPCRBundle, as its particularly useful with phpcr data...
I do think that this should be in SonataAdmin -- it has really nothing to do with PHPCR, it maps equally well to an array
field in ORM for example.
it should be in the symfony form component then :-) but well, we have to put it somewhere we have control over. so the base SonataAdminBundle sounds ok to me
this would also allow editing of
childrenAttributes / Keys linkAttributes / Keys attributes / Keys
is there anywhere anyone working on this? or any further discussion taking place?
@phiamo No i dont think anyone is particularly committed to this at this point. I think its a strong candidate for trying to get into 1.1 since its so multi-purpose
@phiamo i would love this to happen if you have time to work on it. best send an email to symfony-cmf-devs@googlegroups.com so that everybody is aware you are working on it, to avoid duplicated work. and also if you need any help. i think the hard part is making it actually work - and then figuring out into which repository this really belongs, but for that the mailinglist is the right place to discuss.
@dbu i dont think i will have time nor insight in the next few weeks to go on this :/
@dbu i would love to have that feature, but i dont have any idea yet where to start ... we will need some generic data transformer or is there already one capable of nested hashmaps? We need to add this to the admin forms one by one. What else did i miss?
bart van den burg created a form type for editing key-value maps: https://github.com/Burgov/KeyValueFormBundle
i think you can leverage that one for editing the defaults and then you are set. you should not need any nested hashmaps, as the route parameters need to be strings anyways if i am not mistaken.
we should not add a dependency on that bundle to the menu bundle but explain in the doc that for sonata it is required. wdyt?
if "someone" figures out how to include this and document it that would be awesome, which doc would you append that info into, or wouldyou create anew one?
i think for the doc, it could be mentioned in https://github.com/symfony-cmf/symfony-cmf-docs/blob/master/bundles/phpcr_odm.rst#form-types as an additional form type that can be handy.
then the DoctrinePHPCRBundle could suggest the keyvalueformbundle and require-dev it, and adjust the form type guesser to use it - if the class_exists. see https://github.com/doctrine/DoctrinePHPCRBundle/pull/93/files#diff-2 and https://github.com/doctrine/DoctrinePHPCRBundle/issues/111
do you want to give it a shot?
@dbu https://github.com/doctrine/DoctrinePHPCRBundle/pull/120 a shot...
https://github.com/doctrine/DoctrinePHPCRBundle/pull/120 is merged. anything left to do here?
When you create a menu node, it can be of type "route" and point at a symfony route.
If the symfony route accepts parameters, I am not sure how you can go about setting those parameters on the menu node.
For example, if the route projects_by_category has a parameter named slug, how can you add a MenuNode that will link to this route with the slug parameter set to "foo".
It looks like the ContentAwareFactory already calls getOptions on the MenuNode when it is being created, so if that returned an array with the key routeParameters then those route parameters would be included in the url that is generated. It also looks like MenuNodeBase has a routeParameters member variable that is mapped as an assoc multi value field, so it looks like the only missing piece is a way to specify route parameters when editing a MenuNode.
Providing this functionality (editing a multi value phpcr field while preserving keys) is a more general question. Is there something in sonata phpcr admin that could be used for this? This also relates to a general question about how to map data via a symfony form when the property path would require multiple arguments when called. In other words I need to call $model->setRouteParameter('slug', 'value') rather than just $model->setRouteParameter('value')