当前位置: 首页>>代码示例>>PHP>>正文


PHP FormMapper::end方法代码示例

本文整理汇总了PHP中Sonata\AdminBundle\Form\FormMapper::end方法的典型用法代码示例。如果您正苦于以下问题:PHP FormMapper::end方法的具体用法?PHP FormMapper::end怎么用?PHP FormMapper::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sonata\AdminBundle\Form\FormMapper的用法示例。


在下文中一共展示了FormMapper::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with('Général', array('class' => "col-md-6"));
     $formMapper->add('name', 'text', array("label" => "Nom de papier"));
     $formMapper->add('marge', 'text', array("label" => "Marge entre les element"));
     $formMapper->add('nbpage', 'choice', array("label" => "Nomber des page", 'choices' => array('1' => '1', '2' => '2')));
     $formMapper->end();
     $formMapper->with("Elements", array('class' => "col-md-6"));
     $formMapper->add('width', 'text', array("label" => "Largeur"));
     $formMapper->add('height', 'text', array("label" => "Hauteur"));
     $formMapper->end();
     $formMapper->with('PDF', array('class' => "col-md-12"));
     $formMapper->add('pdflist', 'sonata_type_collection', array('by_reference' => false), array('edit' => 'inline', 'inline' => 'table', 'sortable' => 'position'));
     $formMapper->end();
 }
开发者ID:saliih,项目名称:yasmine-print,代码行数:15,代码来源:PdfmergeAdmin.php

示例2: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with(' ', array('class' => 'col-md-8'));
     $formMapper->add('name', 'text', array("label" => "Nom de la catégorie"));
     $formMapper->add('color', 'text', array("label" => "Couleur de la catégorie"));
     //sonata_type_color_selector
     $formMapper->add('costumise', null, array("label" => "Personisable?", 'required' => false));
     $formMapper->add('picture', null, array("label" => "Image", 'required' => false));
     $formMapper->add('descript');
     $formMapper->end();
     $formMapper->with('Type des Plis', array('class' => 'col-md-4'));
     $formMapper->add('plis', null, array('required' => false, 'expanded' => true, 'mapped' => true, "multiple" => true, "label" => false));
     $formMapper->end();
     $formMapper->with('Options')->add('options', 'sonata_type_collection', array('by_reference' => false), array('edit' => 'inline', 'inline' => 'table', 'sortable' => 'position'))->end();
 }
开发者ID:saliih,项目名称:yasmine-print,代码行数:15,代码来源:CategoriesAdmin.php

示例3: configureFormFields

 /**
  * @param FormMapper $formMapper
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with('fc.label.admin.with.form_main')->add('Title', null, array('label' => 'fc.label.admin.title'))->add('Alias', null, array('label' => 'fc.label.admin.alias', 'constraints' => array(new Regex(array('pattern' => '/^\\w+$/', 'message' => 'fc.constraint.admin.not_alphanumeric')))))->add('Message', $this->fc_defaults['text_editor'], array('label' => 'fc.label.admin.message', 'required' => false));
     if (!$this->getSubject()->isNew()) {
         $formMapper->add('IsActive', null, array('label' => 'fc.label.admin.is_active', 'required' => false));
     }
     $formMapper->end()->with('fc.label.admin.with.form_additional')->add('Method', 'choice', array('label' => 'fc.label.admin.method', 'choices' => array('POST' => 'POST', 'GET' => 'GET')))->add('Action', null, array('label' => 'fc.label.admin.action'))->add('Button', null, array('label' => 'fc.label.admin.button'))->add('IsAjax', null, array('label' => 'fc.label.admin.is_ajax', 'required' => false))->add('IsWidget', null, array('label' => 'fc.label.admin.is_widget', 'required' => false))->end()->setHelps(array('Alias' => 'fc.help.admin.alias', 'Action' => 'fc.help.admin.action', 'Button' => 'fc.help.admin.button', 'IsAjax' => 'fc.help.admin.is_ajax', 'IsWidget' => 'fc.help.admin.is_widget'));
 }
开发者ID:it-blaster,项目名称:form-constructor-bundle,代码行数:11,代码来源:FcFormAdmin.php

示例4: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $subject = $this->getSubject();
     $formMapper->with('Status')->add('enabled', null, array('required' => false));
     if ($subject->isStudent()) {
         $formMapper->add('visible', 'checkbox', array('label' => 'Student Visible', 'required' => false));
     }
     $formMapper->end();
     $formMapper->with('Account Details')->add('type', 'choice', array('label' => 'Account Type', 'choices' => User::getRolesArray()))->add('email')->add('firstName')->add('lastName')->add('plainPassword', 'text', array('required' => false, 'label' => 'New Password'))->end();
 }
开发者ID:hoangnd25,项目名称:IndustryProject,代码行数:10,代码来源:UserAdmin.php

示例5: configureFormFields

 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->tab('General')->with('Basic Info')->add('username')->add('email')->add('plainPassword', 'text', array('required' => !$this->getSubject() || is_null($this->getSubject()->getId())))->end()->end();
     $formMapper->tab('Groups & Roles')->with('Groups')->add('groups', 'sonata_type_model', array('required' => false, 'expanded' => true, 'multiple' => true))->end();
     if ($this->getSubject() && !$this->getSubject()->hasRole('ROLE_SUPER_ADMIN')) {
         $formMapper->with('Roles')->add('realRoles', 'sonata_security_roles', array('label' => 'form.label_roles', 'expanded' => true, 'multiple' => true, 'required' => false))->add('locked', null, array('required' => false))->add('expired', null, array('required' => false))->add('enabled', null, array('required' => false))->add('credentialsExpired', null, array('required' => false))->end();
     }
     $formMapper->end()->tab('Info')->with('Profile')->add('dateOfBirth', 'birthday', array('required' => false))->add('firstname', null, array('required' => false))->add('lastname', null, array('required' => false))->add('website', 'url', array('required' => false))->add('biography', 'text', array('required' => false))->add('gender', 'sonata_user_gender', array('required' => true, 'translation_domain' => $this->getTranslationDomain()))->add('locale', 'locale', array('required' => false))->add('timezone', 'timezone', array('required' => false))->add('phone', null, array('required' => false))->end()->with('Social')->add('facebookUid', null, array('required' => false))->add('facebookName', null, array('required' => false))->add('twitterUid', null, array('required' => false))->add('twitterName', null, array('required' => false))->add('gplusUid', null, array('required' => false))->add('gplusName', null, array('required' => false))->end()->end();
     $formMapper->tab('Security')->with('Two Step Verification')->add('token', null, array('required' => false))->add('twoStepVerificationCode', null, array('required' => false))->end()->end();
     $formMapper->tab('Venues')->add('venues', 'sonata_type_collection', ['label' => 'Venues'])->end();
 }
开发者ID:0xMatt,项目名称:SymNSonata,代码行数:14,代码来源:UserAdmin.php

示例6: addInformationBlock

 function addInformationBlock(FormMapper $formMapper, $title = 'Status')
 {
     $formMapper->with($title, array('class' => 'col-md-4'))->end()->with($title)->add('updatedAt', 'genemu_plain', ['required' => false, 'data_class' => 'DateTime'])->add('createdAt', 'genemu_plain', ['required' => false, 'data_class' => 'DateTime']);
     if (method_exists($this->getSubject(), 'getCreatedBy')) {
         $formMapper->add('createdBy', 'genemu_plain', ['required' => false, 'data_class' => '\\Application\\Sonata\\UserBundle\\Entity\\User']);
     }
     if (method_exists($this->getSubject(), 'getUpdatedBy')) {
         $formMapper->add('updatedBy', 'genemu_plain', ['required' => false, 'data_class' => '\\Application\\Sonata\\UserBundle\\Entity\\User']);
     }
     $formMapper->end();
 }
开发者ID:php-nik,项目名称:IphpCoreBundle,代码行数:11,代码来源:EntityInformationBlock.php

示例7: end

 /**
  * Закончить задание содержания мультиязычной
  * вкладки и передать результат в мапер формы
  * @desc Метод повторяет поведение класса FormMapper
  * @return FormMapper
  */
 public function end()
 {
     $eventSubscriber = new AddTranslationFieldSubscriber($this->em, $this->localeManager, $this->mappingFactory, $this->fileStorage);
     $this->formMapper->getFormBuilder()->addEventSubscriber($eventSubscriber);
     $firstTab = true;
     $locales = $this->localeManager->getActiveList();
     $administrator = $this->getTokenStorage()->getToken()->getUser();
     if ($administrator instanceof Administrator) {
         usort($locales, [$administrator, 'sortLocales']);
     }
     foreach ($locales as $localeData) {
         $tabName = $localeData->getName();
         if (strlen($this->tabName) > 0) {
             $tabName = str_replace('%locale_name%', $localeData->getName(), $this->tabName);
         }
         $tabOptions = [];
         if ($this->isDisabledByAdministratorLocales($localeData->getAlias())) {
             $tabOptions = ['class' => 'disabled'];
         }
         $this->formMapper->with($tabName, $tabOptions);
         foreach ($this->fields as $fieldData) {
             if (!$firstTab && (!isset($fieldData['options']['translatable']) || !$fieldData['options']['translatable'])) {
                 continue;
             }
             $fieldName = $fieldData['name'];
             if (isset($fieldData['options']['translatable'])) {
                 if ($fieldData['options']['translatable']) {
                     $fieldName = 'translation___' . $fieldData['name'] . '___' . $localeData->getAlias();
                     $fieldData['options']['mapped'] = false;
                     if (isset($fieldData['options']['locale'])) {
                         $fieldData['options']['locale'] = $localeData->getAlias();
                     }
                     $fieldData['options']['disabled'] = $this->isDisabled($localeData->getAlias(), $fieldData['options']);
                     if ($localeData->getAlias() != $this->localeManager->getDefaultLocaleAlias()) {
                         //убираем обязательность полей для языков
                         $fieldData['options']['required'] = false;
                         if (!empty($fieldData['options']['inner_constraints'])) {
                             foreach ($fieldData['options']['inner_constraints'] as $key => $value) {
                                 if ($value instanceof FileNotBlank) {
                                     unset($fieldData['options']['inner_constraints'][$key]);
                                 }
                             }
                         }
                     }
                 }
                 unset($fieldData['options']['translatable']);
             }
             $this->formMapper->add($fieldName, $fieldData['type'], $fieldData['options'], $fieldData['fieldDescriptionOptions']);
         }
         $this->formMapper->end();
         $firstTab = false;
     }
     return $this->formMapper;
 }
开发者ID:octava,项目名称:cms,代码行数:60,代码来源:TranslationMapper.php

示例8: configureFormFields

 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $normalUser = $this->getSubject() && !$this->getSubject()->hasRole('ROLE_SUPER_ADMIN');
     $formMapper->tab('Général')->with('Utilisateur', array('class' => 'col-md-6'))->add('username')->add('email')->add('plainPassword', 'text', array('required' => !$this->getSubject() || is_null($this->getSubject()->getId())))->add('firstname')->add('lastname')->add('company', null, array('label' => 'Société'))->add('legalSituation', 'choice', array('choices' => array('ei' => 'Entreprises individuelles', 'sc' => 'Sociétés civiles', 'eurl' => 'EURL', 'sarl' => 'SARL', 'sas' => 'SAS', 'sa' => 'SA'), 'label' => 'Statut juridique :'))->add('phoneNumber', 'text', array('label' => 'Téléphone :'))->add('url', 'url', array('label' => 'Url de votre site :'))->end()->with('Groups', array('class' => 'col-md-6'))->add('groups', 'sonata_type_model', array('required' => false, 'expanded' => true, 'multiple' => true))->end();
     if ($normalUser) {
         $formMapper->with('Management', array('class' => 'col-md-6'))->add('locked', null, array('required' => false))->add('expired', null, array('required' => false))->add('enabled', null, array('required' => false))->add('credentialsExpired', null, array('required' => false))->end();
     }
     $formMapper->end();
     if ($this->getSubject() && !$this->getSubject()->hasRole('ROLE_SUPER_ADMIN')) {
         $formMapper->tab('Rôles')->add('realRoles', 'sonata_security_roles', array('label' => false, 'expanded' => true, 'multiple' => true, 'required' => false))->end();
     }
 }
开发者ID:StanFrag,项目名称:CCM-Stage,代码行数:15,代码来源:UserAdminExtended.php

示例9: configureFormFields

 /**
  * {@inheritdoc}
  * @throws \RuntimeException
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $subject = $this->getSubject();
     $formMapper->tab('General')->with('General');
     if ($subject instanceof MediaFile) {
         $formMapper->add('fileLocation', 'text', array('label' => 'File location on server'));
     }
     if ($subject instanceof MediaUrl) {
         $formMapper->add('url', 'text', array('label' => 'URL to videofile'));
     }
     $formMapper->end()->end();
 }
开发者ID:martin1982,项目名称:live-broadcast-bundle,代码行数:16,代码来源:InputAdmin.php

示例10: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with('tabs.client.basic_data');
     $formMapper->add('enabled', null, array('label' => 'client.enabled', 'required' => false));
     $formMapper->add('name', null, array('label' => 'client.name'));
     $formMapper->add('email', 'email', array('label' => 'client.email'));
     $formMapper->add('phone', null, array('label' => 'client.phone'));
     $formMapper->end();
     $formMapper->with('tabs.client.invoice_data');
     $formMapper->add('invoice_name', null, array('label' => 'client.invoice_name'));
     $formMapper->add('invoice_nip', null, array('label' => 'client.invoice_nip'));
     $formMapper->add('invoice_address', null, array('label' => 'client.invoice_address'));
 }
开发者ID:siciarek,项目名称:ad-rotator-bundle,代码行数:13,代码来源:ClientAdmin.php

示例11: configureFormFields

 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with('General', array('class' => 'col-md-6'))->add('name')->add('description', 'textarea', array('required' => false));
     if ($this->hasSubject()) {
         if ($this->getSubject()->getParent() !== null || $this->getSubject()->getId() === null) {
             // root category cannot have a parent
             $formMapper->add('parent', 'sonata_category_selector', array('category' => $this->getSubject() ?: null, 'model_manager' => $this->getModelManager(), 'class' => $this->getClass(), 'required' => true, 'context' => $this->getSubject()->getContext()));
         }
     }
     $formMapper->end()->with('Options', array('class' => 'col-md-6'))->add('enabled')->add('position', 'integer', array('required' => false, 'data' => 0))->end();
     if (interface_exists('Sonata\\MediaBundle\\Model\\MediaInterface')) {
         $formMapper->with('General')->add('media', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('provider' => 'sonata.media.provider.image', 'context' => 'sonata_category')))->end();
     }
 }
开发者ID:rarekit,项目名称:SonataClassificationBundle,代码行数:17,代码来源:CategoryAdmin.php

示例12: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $subject = $this->getSubject();
     $readonly = false;
     if ($this->id($subject)) {
         $readonly = true;
     }
     $formMapper->tab('general');
     $formMapper->with('customer', array('class' => 'order col-md-4'));
     $formMapper->add('partner', 'sonata_type_model_autocomplete', array('label' => false, 'property' => 'name', 'read_only' => $readonly), array('admin_code' => 'app.customer'));
     $formMapper->end();
     $class = 'order col-md-6';
     $formMapper->with('order_data', array('class' => 'order col-md-4'))->add('id', null, array('label' => 'order_id', 'read_only' => true))->add('orderDate', 'date', array('label' => 'orderdate', 'widget' => 'single_text'))->add('shippingTerm', null, array('horizontal_input_wrapper_class' => array('class' => 'XXXX')))->add('paymentTerm')->end();
     $formMapper->with('more_order_data', array('class' => 'order col-md-4'))->add('state', 'choice', array('label' => 'state', 'choices' => SaleOrder::getStateChoices()))->end();
     $formMapper->with('invoiceaddress', array('class' => $class))->add('invoiceName', null, array('label' => 'name', 'required' => false))->add('invoiceStreet1', null, array('label' => 'street', 'required' => false))->add('invoiceStreet2', null, array('label' => 'street_addon', 'required' => false))->add('invoiceZip', null, array('label' => 'zip', 'required' => false))->add('invoiceCity', null, array('label' => 'city', 'required' => false))->add('invoiceCountry', 'country', array('label' => 'country', 'attr' => array('class' => 'country'), 'required' => false))->end()->with('shippingaddress', array('class' => $class))->add('shippingName', null, array('label' => 'name', 'required' => false))->add('shippingStreet1', null, array('label' => 'street', 'required' => false))->add('shippingStreet2', null, array('label' => 'street_addon', 'required' => false))->add('shippingZip', null, array('label' => 'zip', 'required' => false))->add('shippingCity', null, array('label' => 'city', 'required' => false))->add('shippingCountry', 'country', array('label' => 'country', 'attr' => array('class' => 'country'), 'required' => false))->end()->with('memo', array('class' => 'order col-md-12'))->add('orderDate', 'date', array('label' => 'orderdate', 'widget' => 'single_text'))->add('memo', 'textarea', array('label' => false, 'required' => false))->end()->end()->tab('positions')->add('saleOrderLines', 'sonata_type_collection', array('by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->add('amountUntaxed', 'money', array('label' => 'amount_untaxed', 'currency' => 'CHF', 'read_only' => true, 'required' => false))->add('amountTotal', 'money', array('label' => 'amount_total', 'currency' => 'CHF', 'read_only' => true, 'required' => false))->end();
 }
开发者ID:Nexotap,项目名称:Ivory,代码行数:16,代码来源:SaleOrderAdmin.php

示例13: configureFormFields

    protected function configureFormFields(FormMapper $formMapper)
    {
        $img = '';
        if ($this->getSubject()->getId()) {
            $path = $this->getSubject()->getPath();
            if (preg_match('|^https?://|', $path)) {
                $src = $path;
            } else {
                $temp = array($this->getRequest()->getSchemeAndHttpHost(), $this->getSubject()->getWebPath());
                $src = implode('/', $temp);
            }
            if (preg_match('/\\.swf$/', $src) > 0) {
                $params = $this->getSubject()->getType()->getDefinition();
                $width = $params['width'];
                $height = $params['height'];
                $fmt = <<<IMG
<object width="%d" height="%d" align="middle" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
    <param name="allowFullScreen" value="false">
    <param name="movie" value="%s">
    <param name="quality" value="high">
    <param name="scale" value="noscale">
    <param name="salign" value="lt">
    <param name="wmode" value="opaque">
    <param name="allowScriptAccess" value="never">
    <embed width="%d" height="%d" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="never" allowfullscreen="false" salign="LT" scale="noscale" wmode="opaque" quality="high" src="%s"/>
</object>
IMG;
                $img = sprintf($fmt, $width, $height, $src, $width, $height, $src);
            } else {
                $img = '<img style="border:1px solid silver" src="' . $src . '"/>';
            }
        }
        $em = $this->getConfigurationPool()->getContainer()->get('doctrine.orm.entity_manager');
        $type_id = $this->getRequest()->get('type', 0);
        if ($type_id === 0) {
            if ($this->getSubject()->getId() === null) {
                $types = $em->getRepository('SiciarekAdRotatorBundle:AdType')->findAll();
                /**
                 * @var AdType $t
                 */
                $type = array_shift($types);
                $type_id = count($types) > 0 ? $type->getId() : 0;
            } else {
                $type_id = $this->getSubject()->getType()->getId();
            }
        }
        $option_options = array('label' => 'sale.option', 'required' => true, 'expanded' => true, 'multiple' => false);
        $preferred_type = $em->getRepository('SiciarekAdRotatorBundle:AdType')->find($type_id);
        if ($preferred_type instanceof AdType) {
            $option_options['choices'] = $preferred_type->getPrices();
        }
        $type_onchange = sprintf('var url=location.href.replace(/\\?.*$/, "")+"?type="+this.value;location.href=url');
        $option = 0;
        if ($this->getSubject()->getId() === null) {
            $type_options['preferred_choices'] = array($preferred_type);
        } else {
            $this->getSubject()->setType($preferred_type);
        }
        $formMapper->with('tabs.sale.sale');
        $formMapper->add('enabled', null, array('label' => 'sale.enabled', 'required' => false));
        $formMapper->add('type', null, array('label' => 'sale.type', 'required' => true, 'attr' => array('onchange' => $type_onchange)));
        $formMapper->add('option', null, $option_options);
        $formMapper->add('client', 'sonata_type_model', array('label' => 'sale.client', 'required' => true, 'empty_value' => 'Select from list'));
        $formMapper->add('title', null, array('label' => 'sale.title', 'trim' => true, 'required' => false, 'help' => 'Jeżeli tytuł nie zostanie podany wprowadzona zostanie nazwa klienta.'));
        $formMapper->add('leads_to', 'url', array('label' => 'sale.leads_to', 'trim' => true, 'required' => false));
        $formMapper->add('uploaded_file', 'file', array('label' => 'sale.file', 'required' => false, 'help' => $img));
        $formMapper->end();
        $formMapper->with('tabs.sale.displaying_params');
        $formMapper->add('exclusive', null, array('label' => 'sale.exclusive', 'required' => false));
        $formMapper->add('everlasting', null, array('label' => 'sale.everlasting', 'required' => false));
        $formMapper->add('starts_at', new DatePickerType(), array('label' => 'sale.starts_at', 'required' => false));
        $formMapper->end();
        $formMapper->with('tabs.sale.url');
        $formMapper->add('path', null, array('label' => 'sale.path', 'trim' => true, 'required' => false, 'help' => 'help.sale.path'));
    }
开发者ID:siciarek,项目名称:ad-rotator-bundle,代码行数:75,代码来源:AdAdmin.php

示例14: configureFormFields

 /**
  * {@inheritdoc}
  * @throws \RuntimeException
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $subject = $this->getSubject();
     $nameClasses = 'generic-channel-name';
     if ($subject instanceof ChannelYouTube) {
         $nameClasses = 'generic-channel-name input-yt-channelname';
     }
     $formMapper->with('Channel')->add('channelName', 'text', array('label' => 'Channel name', 'attr' => array('class' => $nameClasses)));
     if ($subject instanceof ChannelTwitch || $subject instanceof ChannelUstream) {
         $formMapper->add('streamKey', 'text', array('label' => 'Stream key'));
         $formMapper->add('streamServer', 'text', array('label' => 'Stream server'));
     }
     if ($subject instanceof ChannelFacebook) {
         $formMapper->add('accessToken', 'hidden', array('attr' => array('class' => 'fb-access-token')));
         $formMapper->add('fbEntityId', 'hidden', array('attr' => array('class' => 'fb-entity-id')));
     }
     if ($subject instanceof ChannelYouTube) {
         $formMapper->add('youTubeChannelName', 'text', array('attr' => array('class' => 'input-yt-channelname', 'readonly' => 'readonly')));
         $formMapper->add('refreshToken', 'text', array('attr' => array('class' => 'input-yt-refreshtoken', 'readonly' => 'readonly')));
     }
     $formMapper->end();
 }
开发者ID:martin1982,项目名称:live-broadcast-bundle,代码行数:26,代码来源:ChannelAdmin.php

示例15: configureFormFields

 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $block = $this->getSubject();
     $dashboard = false;
     if ($this->getParent()) {
         $dashboard = $this->getParent()->getSubject();
         if (!$dashboard instanceof DashboardInterface) {
             throw new \RuntimeException('The BlockAdmin must be attached to a parent DashboardAdmin');
         }
         if ($block->getId() === null) {
             // new block
             $block->setType($this->request->get('type'));
             $block->setDashboard($dashboard);
         }
         if ($block->getDashboard()->getId() != $dashboard->getId()) {
             throw new \RuntimeException('The dashboard reference on BlockAdmin and parent admin are not the same');
         }
     }
     $isComposer = $this->hasRequest() ? $this->getRequest()->get('composer', false) : false;
     $generalGroupOptions = $optionsGroupOptions = array();
     if ($isComposer) {
         $generalGroupOptions['class'] = 'hidden';
         $optionsGroupOptions['name'] = '';
     }
     $formMapper->with($this->trans('form.field_group_general'), $generalGroupOptions);
     $containerBlockTypes = $this->containerBlockTypes;
     $isContainerRoot = $block && in_array($block->getType(), $containerBlockTypes) && !$this->hasParentFieldDescription();
     $isStandardBlock = $block && !in_array($block->getType(), $containerBlockTypes) && !$this->hasParentFieldDescription();
     if (!$isComposer) {
         $formMapper->add('name');
     } elseif (!$isContainerRoot) {
         $formMapper->add('name', 'hidden');
     }
     $formMapper->end();
     if ($isContainerRoot || $isStandardBlock) {
         $formMapper->with($this->trans('form.field_group_general'), $generalGroupOptions);
         $service = $this->blockManager->get($block);
         // need to investigate on this case where $dashboard == null ... this should not be possible
         if ($isStandardBlock && $dashboard && !empty($containerBlockTypes)) {
             $formMapper->add('parent', 'entity', array('class' => $this->getClass(), 'query_builder' => function (EntityRepository $repository) use($dashboard, $containerBlockTypes) {
                 return $repository->createQueryBuilder('a')->andWhere('a.dashboard = :dashboard AND a.type IN (:types)')->setParameters(array('dashboard' => $dashboard, 'types' => $containerBlockTypes));
             }), array('admin_code' => $this->getCode()));
         }
         if ($isComposer) {
             $formMapper->add('enabled', 'hidden', array('data' => true));
         } else {
             $formMapper->add('enabled');
         }
         if ($isStandardBlock) {
             $formMapper->add('position', 'integer');
         }
         $formMapper->end();
         $formMapper->with($this->trans('form.field_group_options'), $optionsGroupOptions);
         if ($block->getId() > 0) {
             $service->buildEditForm($formMapper, $block);
         } else {
             $service->buildCreateForm($formMapper, $block);
         }
         // When editing a container in composer view, hide some settings
         if ($isContainerRoot && $isComposer) {
             $formMapper->remove('children');
             $formMapper->add('name', 'text', array('required' => true));
             $formSettings = $formMapper->get('settings');
             $formSettings->remove('code');
             $formSettings->remove('layout');
             $formSettings->remove('template');
         }
         $formMapper->end();
     } else {
         $formMapper->with($this->trans('form.field_group_options'), $optionsGroupOptions)->add('type', 'sonata_block_service_choice', array('context' => 'sonata_dashboard_bundle'))->add('enabled')->add('position', 'integer')->end();
     }
 }
开发者ID:hason,项目名称:SonataDashboardBundle,代码行数:75,代码来源:BlockAdmin.php


注:本文中的Sonata\AdminBundle\Form\FormMapper::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。