/**
  * {@inheritdoc}
  */
 public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
 {
     $contextChoices = array();
     foreach ($this->pool->getContexts() as $name => $context) {
         $contextChoices[$name] = $name;
     }
     $formMapper->add('settings', 'sonata_type_immutable_array', array('keys' => array(array('title', 'text', array('label' => 'form.label_title', 'required' => false)), array('number', 'integer', array('label' => 'form.label_number', 'required' => true)), array('context', 'choice', array('required' => true, 'label' => 'form.label_context', 'choices' => $contextChoices)), array('mode', 'choice', array('label' => 'form.label_mode', 'choices' => array('public' => 'form.label_mode_public', 'admin' => 'form.label_mode_admin'))), array('order', 'choice', array('label' => 'form.label_order', 'choices' => array('name' => 'form.label_order_name', 'createdAt' => 'form.label_order_created_at', 'updatedAt' => 'form.label_order_updated_at'))), array('sort', 'choice', array('label' => 'form.label_sort', 'choices' => array('desc' => 'form.label_sort_desc', 'asc' => 'form.label_sort_asc')))), 'translation_domain' => 'SonataMediaBundle'));
 }
 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     // define group zoning
     $formMapper->with($this->trans('Gallery'), array('class' => 'col-md-9'))->end()->with($this->trans('Options'), array('class' => 'col-md-3'))->end();
     $context = $this->getPersistentParameter('context');
     if (!$context) {
         $context = $this->pool->getDefaultContext();
     }
     $formats = array();
     foreach ((array) $this->pool->getFormatNamesByContext($context) as $name => $options) {
         $formats[$name] = $name;
     }
     $contexts = array();
     foreach ((array) $this->pool->getContexts() as $contextItem => $format) {
         $contexts[$contextItem] = $contextItem;
     }
     $formMapper->with('Options')->add('context', 'sonata_type_translatable_choice', array('choices' => $contexts, 'catalogue' => 'SonataMediaBundle'))->add('enabled', null, array('required' => false))->add('name')->add('defaultFormat', 'choice', array('choices' => $formats))->end()->with('Gallery')->add('galleryHasMedias', 'sonata_type_collection', array('cascade_validation' => true), array('edit' => 'inline', 'inline' => 'table', 'sortable' => 'position', 'link_parameters' => array('context' => $context), 'admin_code' => 'sonata.media.admin.gallery_has_media'))->end();
 }