Browse Source

add a link_parameters option

Thomas 14 years ago
parent
commit
842b7c0094
2 changed files with 7 additions and 2 deletions
  1. 5 2
      Admin/Admin.php
  2. 2 0
      Admin/FieldDescription.php

+ 5 - 2
Admin/Admin.php

@@ -774,8 +774,11 @@ abstract class Admin implements AdminInterface
             $parameters[$this->getParent()->getIdParameter()] = $this->request->get($this->getParent()->getIdParameter());
         }
 
-        // if the admin is linked to a FieldDescription (ie, embedded widget)
+        // if the admin is lnked to a parent FieldDescription (ie, embedded widget)
         if ($this->hasParentFieldDescription()) {
+            // merge link parameter if any provided by the parent field
+            $parameters = array_merge($parameters, $this->getParentFieldDescription()->getOption('link_parameters', array()));
+            
             $parameters['uniqid']  = $this->getUniqid();
             $parameters['code']    = $this->getCode();
             $parameters['pcode']   = $this->getParentFieldDescription()->getAdmin()->getCode();
@@ -789,7 +792,7 @@ abstract class Admin implements AdminInterface
 
         // allows to define persistent parameters 
         $parameters = array_merge($this->getPersistentParameters(), $parameters);
-        
+
         $url = $this->getUrl($name);
 
         if (!$url) {

+ 2 - 0
Admin/FieldDescription.php

@@ -26,6 +26,8 @@ namespace Sonata\AdminBundle\Admin;
  *   - type (m): define the field type (use to tweak the form or the list)
  *   - template (o) : the template used to render the field
  *   - name (o) : the name used (label in the form, title in the list)
+ *   - link_parameters (o) : add link parameter to the related Admin class when
+ *                           the Admin.generateUrl is called
  *
  * Form Field options :
  *   - form_field_widget (o): the widget class to use to render the field