Browse Source

fix missing admin_code from parent

Thomas Rabaix 10 năm trước cách đây
mục cha
commit
123d6062ca
2 tập tin đã thay đổi với 9 bổ sung4 xóa
  1. 6 2
      Admin/Admin.php
  2. 3 2
      Datagrid/DatagridMapper.php

+ 6 - 2
Admin/Admin.php

@@ -25,8 +25,10 @@ use Sonata\AdminBundle\Form\FormMapper;
 use Sonata\AdminBundle\Datagrid\ListMapper;
 use Sonata\AdminBundle\Datagrid\DatagridMapper;
 use Sonata\AdminBundle\Show\ShowMapper;
-use Sonata\AdminBundle\Validator\ErrorElement;
-use Sonata\AdminBundle\Validator\Constraints\InlineConstraint;
+
+use Sonata\CoreBundle\Validator\ErrorElement;
+use Sonata\CoreBundle\Validator\Constraints\InlineConstraint;
+
 use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface;
 use Sonata\AdminBundle\Builder\FormContractorInterface;
 use Sonata\AdminBundle\Builder\ListBuilderInterface;
@@ -892,6 +894,8 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
                     'model_manager' => $this->getModelManager(),
                 ),
                 'operator_type' => 'hidden',
+            ), null, null, array(
+                'admin_code' => $this->getParent()->getCode()
             ));
         }
 

+ 3 - 2
Datagrid/DatagridMapper.php

@@ -42,10 +42,11 @@ class DatagridMapper extends BaseMapper
      * @param array  $filterOptions
      * @param string $fieldType
      * @param array  $fieldOptions
+     * @param array  $fieldDescriptionOptions
      *
      * @return DatagridMapper
      */
-    public function add($name, $type = null, array $filterOptions = array(), $fieldType = null, $fieldOptions = null)
+    public function add($name, $type = null, array $filterOptions = array(), $fieldType = null, $fieldOptions = null, array $fieldDescriptionOptions = array())
     {
         if (is_array($fieldOptions)) {
             $filterOptions['field_options'] = $fieldOptions;
@@ -70,7 +71,7 @@ class DatagridMapper extends BaseMapper
             $fieldDescription = $this->admin->getModelManager()->getNewFieldDescriptionInstance(
                 $this->admin->getClass(),
                 $name,
-                $filterOptions
+                array_merge($filterOptions, $fieldDescriptionOptions)
             );
         } else {
             throw new \RuntimeException('Unknown field name in datagrid mapper. Field name should be either of FieldDescriptionInterface interface or string.');