Example #1
0
 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();
 }
Example #2
0
 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();
 }
 /**
  * @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'));
 }
Example #4
0
 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();
 }
Example #5
0
 /**
  * {@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();
 }
 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();
 }
Example #7
0
 /**
  * Закончить задание содержания мультиязычной
  * вкладки и передать результат в мапер формы
  * @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;
 }
Example #8
0
 /**
  * {@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();
     }
 }
 /**
  * {@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();
 }
 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'));
 }
 /**
  * {@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();
     }
 }
Example #12
0
 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();
 }
Example #13
0
    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'));
    }
 /**
  * {@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();
 }
 /**
  * {@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();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $block = $this->getSubject();
     $page = false;
     if ($this->getParent()) {
         $page = $this->getParent()->getSubject();
         if (!$page instanceof PageInterface) {
             throw new \RuntimeException('The BlockAdmin must be attached to a parent PageAdmin');
         }
         if ($block->getId() === null) {
             // new block
             $block->setType($this->request->get('type'));
             $block->setPage($page);
         }
         if ($block->getPage()->getId() != $page->getId()) {
             throw new \RuntimeException('The page reference on BlockAdmin and parent admin are not the same');
         }
     }
     $blockType = $block->getType();
     $isComposer = $this->hasRequest() ? $this->getRequest()->get('composer', false) : false;
     $generalGroupOptions = $optionsGroupOptions = array();
     if ($isComposer) {
         $generalGroupOptions['class'] = 'hidden';
         $optionsGroupOptions['name'] = '';
     }
     $formMapper->with('form.field_group_general', $generalGroupOptions);
     if (!$isComposer) {
         $formMapper->add('name');
     } else {
         $formMapper->add('name', 'hidden');
     }
     $formMapper->end();
     $isContainerRoot = $block && in_array($blockType, array('sonata.page.block.container', 'sonata.block.service.container')) && !$this->hasParentFieldDescription();
     $isStandardBlock = $block && !in_array($blockType, array('sonata.page.block.container', 'sonata.block.service.container')) && !$this->hasParentFieldDescription();
     if ($isContainerRoot || $isStandardBlock) {
         $formMapper->with('form.field_group_general', $generalGroupOptions);
         $service = $this->blockManager->get($block);
         $containerBlockTypes = $this->containerBlockTypes;
         // need to investigate on this case where $page == null ... this should not be possible
         if ($isStandardBlock && $page && !empty($containerBlockTypes)) {
             $formMapper->add('parent', 'entity', array('class' => $this->getClass(), 'query_builder' => function (EntityRepository $repository) use($page, $containerBlockTypes) {
                 return $repository->createQueryBuilder('a')->andWhere('a.page = :page AND a.type IN (:types)')->setParameters(array('page' => $page, '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('form.field_group_options', $optionsGroupOptions);
         if ($block->getId() > 0) {
             $service->buildEditForm($formMapper, $block);
         } else {
             $service->buildCreateForm($formMapper, $block);
         }
         if ($formMapper->has('settings') && isset($this->blocks[$blockType]['templates'])) {
             $settingsField = $formMapper->get('settings');
             if (!$settingsField->has('template')) {
                 $choices = array();
                 if (null !== ($defaultTemplate = $this->getDefaultTemplate($service))) {
                     $choices[$defaultTemplate] = 'default';
                 }
                 foreach ($this->blocks[$blockType]['templates'] as $item) {
                     $choices[$item['template']] = $item['name'];
                 }
                 if (count($choices) > 1) {
                     $settingsField->add('template', 'choice', array('choices' => $choices));
                 }
             }
         }
         $formMapper->end();
     } else {
         $formMapper->with('form.field_group_options', $optionsGroupOptions)->add('type', 'sonata_block_service_choice', array('context' => 'sonata_page_bundle'))->add('enabled')->add('position', 'integer')->end();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildEditForm(FormMapper $formMapper, $isVariation = false)
 {
     $formMapper->with('Product');
     $formMapper->add('name');
     $formMapper->add('sku');
     if (!$isVariation || in_array('description', $this->variationFields)) {
         $formMapper->add('description', 'sonata_formatter_type', array('source_field' => 'rawDescription', 'source_field_options' => array('attr' => array('class' => 'span10', 'rows' => 20)), 'format_field' => 'descriptionFormatter', 'target_field' => 'description', 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher()));
     }
     if (!$isVariation || in_array('short_description', $this->variationFields)) {
         $formMapper->add('shortDescription', 'sonata_formatter_type', array('source_field' => 'rawShortDescription', 'source_field_options' => array('attr' => array('class' => 'span10', 'rows' => 20)), 'format_field' => 'shortDescriptionFormatter', 'target_field' => 'shortDescription', 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher()));
     }
     $formMapper->add('price', 'number')->add('priceIncludingVat')->add('vatRate', 'number')->add('stock', 'integer');
     if (!$isVariation || in_array('image', $this->variationFields)) {
         $formMapper->add('image', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('context' => 'sonata_product', 'filter' => array('context' => array('value' => 'sonata_product')), 'provider' => '')));
     }
     if (!$isVariation || in_array('gallery', $this->variationFields)) {
         $formMapper->add('gallery', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('context' => 'sonata_product', 'filter' => array('context' => array('value' => 'sonata_product')), 'provider' => '')));
     }
     $formMapper->add('enabled');
     $formMapper->end();
     $formMapper->with('Categories')->add('productCategories', 'sonata_type_collection', array('required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table', 'link_parameters' => array('provider' => $this->getCode())))->end()->with('Collections')->add('productCollections', 'sonata_type_collection', array('required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table', 'link_parameters' => array('provider' => $this->getCode())))->end()->with('Deliveries')->add('deliveries', 'sonata_type_collection', array('required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table', 'link_parameters' => array('provider' => $this->getCode())))->end();
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     /** @var $pageManager PageManagerInterface */
     $pageManager = $this->getContainer()->get('networking_init_cms.page_manager');
     $this->getRequest()->attributes->add(array('page_locale' => $this->pageLocale));
     try {
         $request = $this->getRequest();
     } catch (\RuntimeException $e) {
         $request = $this->getContainer()->get('request');
     }
     if ($this->getSubject()->getId() || $request->isXmlHttpRequest()) {
         $formMapper->with('page_content')->add('layoutBlock', 'sonata_type_collection', array('required' => true, 'label' => false, 'label_render' => false, 'error_bubbling' => false, 'type_options' => array('error_bubbling' => false)))->end();
     }
     $formMapper->with('page_settings');
     if ($this->canCreateHomepage && !$this->getSubject()->getId()) {
         $formMapper->add('isHome', null, array('required' => false), array('inline_block' => true));
     }
     if (!$this->getSubject()->getId()) {
         $formMapper->add('locale', 'choice', array('choices' => $this->getLocaleChoices(), 'preferred_choices' => array($this->pageLocale), 'help_block' => 'locale.helper.text'));
     }
     $formMapper->add('pageName', null, array('help_block' => 'page_name.helper.text'));
     if (!$this->canCreateHomepage) {
         if (!$this->getSubject()->getId() || !$this->getSubject()->isHome()) {
             $formMapper->add('parent', 'networking_type_autocomplete', array('help_block' => 'parent.helper.text', 'attr' => array('style' => "width:220px"), 'property' => 'AdminTitle', 'class' => $this->getClass(), 'required' => false, 'query_builder' => $pageManager->getParentPagesQuery($this->pageLocale, $this->getSubject()->getId(), false, false)));
         }
         if (!$this->getSubject()->getId() || !$this->getSubject()->isHome()) {
             $formMapper->add('alias', 'networking_type_autocomplete', array('help_block' => 'alias.helper.text', 'attr' => array('style' => "width:220px"), 'property' => 'AdminTitle', 'class' => $this->getClass(), 'required' => false, 'query_builder' => $pageManager->getParentPagesQuery($this->pageLocale, $this->getSubject()->getId(), true, true)), array('display_method' => 'getAliasFullPath'));
         }
     }
     $requireUrl = $this->canCreateHomepage ? false : true;
     if ($this->getSubject()->getId()) {
         $formMapper->add('url', null, array('required' => $requireUrl, 'read_only' => $this->getSubject()->isHome(), 'help_label' => $this->getSubject()->getFullPath(), 'help_block' => 'url.helper.text'), array('display_method' => 'getFullPath'));
     } elseif (!$this->getSubject()->getId()) {
         $formMapper->add('url', null, array('required' => $requireUrl, 'help_label' => '/', 'help_block' => 'url.helper.text'), array('display_method' => 'getFullPath'));
     }
     $subject = $this->subject;
     $formMapper->add('visibility', 'sonata_type_translatable_choice', array('help_block' => 'visibility.helper.text', 'choices' => $subject::getVisibilityList(), 'catalogue' => $this->translationDomain))->add('activeFrom', 'datetime', array('widget_form_group_attr' => array('class' => 'form-group form-inline'), 'required' => false, 'widget' => 'single_text', 'datetimepicker' => true))->add('activeTo', 'datetime', array('widget_form_group_attr' => array('class' => 'form-group form-inline'), 'required' => false, 'widget' => 'single_text', 'datetimepicker' => true))->add('templateName', 'networking_type_iconradio', array('label' => 'form.label_template', 'horizontal_input_wrapper_class' => 'col-md-12', 'expanded' => true, 'choices' => $this->getPageTemplates(), 'data' => $this->getDefaultTemplate()));
     $formMapper->end();
     // end of group: page_settings
     $formMapper->with('meta_settings')->add('metaTitle', null, array('help_block' => 'meta_title.helper.text'))->add('metaKeyword')->add('metaDescription')->end();
 }
Example #19
0
 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     if (!($locale = $this->getRequest()->get('locale'))) {
         $locale = $this->getRequest()->getLocale();
     }
     $uniqId = $this->getUniqid();
     if ($postArray = $this->getRequest()->get($uniqId)) {
         if (array_key_exists('locale', $postArray)) {
             $locale = $postArray['locale'];
         }
     }
     $er = $this->getContainer()->get('Doctrine')->getRepository('NetworkingInitCmsBundle:MenuItem');
     $id = $this->getRequest()->get('id');
     if ($id) {
         $menuItem = $er->find($id);
         $locale = $menuItem->getLocale();
     }
     if ($rootId = $this->getRequest()->get('root_id')) {
         $root = $er->find($rootId);
     } elseif ($id) {
         $root = $er->find($this->getSubject()->getRoot());
     } else {
         $root = $er->findOneBy(array('isRoot' => 1, 'locale' => $locale));
     }
     if ($this->getRequest()->get('subclass') && $this->getRequest()->get('subclass') == 'menu') {
         $this->isRoot = true;
     } elseif ($this->getSubject()->getIsRoot()) {
         $this->isRoot = true;
     }
     $formMapper->add('locale', 'hidden', array('data' => $locale))->add('name', null, array('horizontal' => true));
     if ($this->isRoot) {
         $formMapper->add('description', null, array('horizontal' => true))->add('isRoot', 'hidden', array('data' => true));
     } else {
         // start group page_or_url
         $formMapper->with('form.legend_page_or_url', array('collapsed' => false, 'description' => $this->translator->trans('form.legend_page_or_url', array(), $this->translationDomain), 'horizontal' => true));
         $pageAdmin = $this->configurationPool->getAdminByAdminCode('networking_init_cms.admin.page');
         $pageClass = $pageAdmin->getClass();
         $formMapper->add('page', 'networking_type_autocomplete', array('attr' => array('style' => "width:220px"), 'class' => $pageClass, 'required' => false, 'horizontal' => true, 'property' => 'AdminTitle', 'query_builder' => function (EntityRepository $er) use($locale) {
             $qb = $er->createQueryBuilder('p');
             $qb->where('p.locale = :locale')->orderBy('p.path', 'asc')->setParameter(':locale', $locale);
             return $qb;
         }));
         $formMapper->add('redirect_url', 'url', array('required' => false, 'help_block' => 'help.redirect_url', 'horizontal' => true));
         $formMapper->add('internal_url', 'text', array('required' => false, 'help_block' => 'help.internal_url', 'horizontal' => true));
         $formMapper->end();
         // start group optionals
         $formMapper->with('Options', array('collapsed' => false, 'description' => $this->translator->trans('form.legend_options', array(), $this->translationDomain), 'horizontal' => true))->add('visibility', 'sonata_type_translatable_choice', array('horizontal' => true, 'help_block' => 'visibility.helper.text', 'choices' => MenuItem::getVisibilityList(), 'catalogue' => $this->translationDomain))->add('link_target', 'choice', array('horizontal' => true, 'choices' => $this->getTranslatedLinkTargets(), 'required' => false))->add('link_class', 'text', array('horizontal' => true, 'required' => false))->add('link_rel', 'text', array('horizontal' => true, 'required' => false))->add('hidden', null, array('horizontal' => true, 'required' => false))->end();
         $entityManager = $this->getContainer()->get('Doctrine')->getManager();
         $transformer = new MenuItemToNumberTransformer($entityManager);
         $menuField = $formMapper->getFormBuilder()->create('menu', 'hidden', array('data' => $root, 'data_class' => null));
         $menuField->addModelTransformer($transformer);
         $formMapper->add($menuField, 'hidden');
     }
 }
Example #20
0
 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $block = $this->getSubject();
     $page = false;
     if ($this->getParent()) {
         $page = $this->getParent()->getSubject();
         if (!$page instanceof PageInterface) {
             throw new \RuntimeException('The BlockAdmin must be attached to a parent PageAdmin');
         }
         if ($block->getId() === null) {
             // new block
             $block->setType($this->request->get('type'));
             $block->setPage($page);
         }
         if ($block->getPage()->getId() != $page->getId()) {
             throw new \RuntimeException('The page reference on BlockAdmin and parent admin are not the same');
         }
     }
     $formMapper->with($this->trans('form.field_group_general'))->add('name')->end();
     $isContainerRoot = $block && in_array($block->getType(), array('sonata.page.block.container', 'sonata.block.service.container')) && !$this->hasParentFieldDescription();
     $isStandardBlock = $block && !in_array($block->getType(), array('sonata.page.block.container', 'sonata.block.service.container')) && !$this->hasParentFieldDescription();
     if ($isContainerRoot || $isStandardBlock) {
         $formMapper->with($this->trans('form.field_group_general'));
         $service = $this->blockManager->get($block);
         $containerBlockTypes = $this->containerBlockTypes;
         // need to investigate on this case where $page == null ... this should not be possible
         if ($isStandardBlock && $page && !empty($containerBlockTypes)) {
             $formMapper->add('parent', 'entity', array('class' => $this->getClass(), 'query_builder' => function (EntityRepository $repository) use($page, $containerBlockTypes) {
                 return $repository->createQueryBuilder('a')->andWhere('a.page = :page AND a.type IN (:types)')->setParameters(array('page' => $page, 'types' => $containerBlockTypes));
             }), array('admin_code' => $this->getCode()));
         }
         $formMapper->add('enabled');
         if ($isStandardBlock) {
             $formMapper->add('position', 'integer');
         }
         $formMapper->end();
         $formMapper->with($this->trans('form.field_group_options'));
         if ($block->getId() > 0) {
             $service->buildEditForm($formMapper, $block);
         } else {
             $service->buildCreateForm($formMapper, $block);
         }
         $formMapper->end();
     } else {
         $formMapper->with($this->trans('form.field_group_options'))->add('type', 'sonata_block_service_choice', array('context' => 'sonata_page_bundle'))->add('enabled')->add('position', 'integer')->end();
     }
 }