Пример #1
0
    /**
     * build the list FieldDescription array
     *
     * @return void
     */
    protected function buildList()
    {
        if ($this->list) {
            return;
        }

        $this->list = $this->getListBuilder()->getBaseList();

        $mapper = new ListMapper($this->getListBuilder(), $this->list, $this);

        if (count($this->getBatchActions()) > 0) {
            $fieldDescription = $this->modelManager->getNewFieldDescriptionInstance($this->getClass(), 'batch', array(
                'label'    => 'batch',
                'code'     => '_batch',
                'sortable' => false
            ));

            $fieldDescription->setAdmin($this);
            $fieldDescription->setTemplate('SonataAdminBundle:CRUD:list__batch.html.twig');

            $mapper->add($fieldDescription, 'batch');
        }

        $this->configureListFields($mapper);
    }
Пример #2
0
 /**
  * make sure the base fields are set in the correct format
  *
  * @param array $selectedFields
  * @return array
  */
 private function getBaseFields(array $selectedFields)
 {
     $fields = array();
     // make sure we works with array
     foreach ($selectedFields as $name => $options) {
         if (!is_array($options)) {
             $name = $options;
             $options = array();
         }
         $description = $this->modelManager->getNewFieldDescriptionInstance($this->getClass(), $name, $options);
         $fields[$name] = $description;
     }
     return $fields;
 }