Beispiel #1
0
 /**
  * Add the types related to the LinkType value.
  *
  * @param                                    $linkType
  * @param                                    $locale
  * @param FormBuilderInterface|FormInterface $form
  * @param FormBuilderInterface               $builder
  */
 protected function manageLinkTypeRelatedFields($linkType, $locale, $form, FormBuilderInterface $builder)
 {
     $form->remove('route');
     $form->remove('url');
     $form->remove('attachedWidget');
     $form->remove('viewReference');
     $form->remove('locale');
     switch ($linkType) {
         case Link::TYPE_VIEW_REFERENCE:
             $locale = $locale ?: $this->requestStack->getCurrentRequest()->getLocale();
             $form->add('viewReference', ChoiceType::class, ['label' => 'form.link_type.view_reference.label', 'required' => true, 'attr' => ['novalidate' => 'novalidate'], 'placeholder' => 'form.link_type.view_reference.blank', 'choices' => $this->viewReferenceRepository->getChoices($locale), 'choices_as_values' => true, 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group']])->add('locale', ChoiceType::class, ['label' => 'form.link_type.locale.label', 'choices' => array_combine($this->availableLocales, $this->availableLocales), 'attr' => ['data-refreshOnChange' => 'true']]);
             break;
         case Link::TYPE_ROUTE:
             $form->add('route', null, ['label' => 'form.link_type.route.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route.placeholder']])->add('route_parameters', JsonType::class, ['label' => 'form.link_type.route_parameters.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route_parameters.placeholder']]);
             break;
         case Link::TYPE_URL:
             $form->add('url', null, ['label' => 'form.link_type.url.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.url.placeholder']]);
             break;
         case Link::TYPE_WIDGET:
             $form->add('attachedWidget', EntityType::class, ['label' => 'form.link_type.attachedWidget.label', 'placeholder' => 'form.link_type.attachedWidget.blank', 'class' => 'VictoireWidgetBundle:Widget', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate']]);
             break;
         case Link::TYPE_NONE:
         case null:
             $form->remove('target');
             break;
     }
 }
 /**
  * @param FormInterface $form
  * @param UserEmailOrigin $emailOrigin
  */
 protected function updateForm(FormInterface $form, UserEmailOrigin $emailOrigin)
 {
     if (!empty($emailOrigin->getAccessToken())) {
         $form->add('checkFolder', 'button', ['label' => $this->translator->trans('oro.email.retrieve_folders.label'), 'attr' => ['class' => 'btn btn-primary']])->add('folders', 'oro_email_email_folder_tree', ['label' => $this->translator->trans('oro.email.folders.label'), 'attr' => ['class' => 'folder-tree'], 'tooltip' => $this->translator->trans('oro.email.folders.tooltip')]);
         $form->remove('check');
     }
 }
Beispiel #3
0
 /**
  * @param FormInterface $form
  * @param string|null   $data
  */
 private function buildForm(FormInterface $form, $data)
 {
     $form->remove('value');
     if ($data === null || in_array($data, TextFilter::getSimpleTypes(), true)) {
         $form->add('value', TextForm::class);
     }
 }
 /**
  * @param FormInterface $form
  * @param $autoplay
  */
 private function manageAutoplaySpeed(FormInterface $form, $autoplay = false)
 {
     if ($autoplay) {
         $form->add('autoplaySpeed', null, ['label' => 'widget_slider.form.autoplaySpeed.label']);
     } else {
         $form->remove('autoplaySpeed');
     }
 }
 /**
  * @param FormInterface $form
  * @param UserEmailOrigin $emailOrigin
  */
 protected function updateForm(FormInterface $form, UserEmailOrigin $emailOrigin)
 {
     //for empty() function must be only variable for compatibility with PHP 5.4
     $token = $emailOrigin->getAccessToken();
     if (!empty($token)) {
         $form->add('checkFolder', 'button', ['label' => $this->translator->trans('oro.email.retrieve_folders.label'), 'attr' => ['class' => 'btn btn-primary']])->add('folders', 'oro_email_email_folder_tree', ['label' => $this->translator->trans('oro.email.folders.label'), 'attr' => ['class' => 'folder-tree'], 'tooltip' => $this->translator->trans('oro.email.folders.tooltip')]);
         $form->remove('check');
     }
 }
Beispiel #6
0
 /**
  * @param FormInterface $form
  * @param string|null   $data
  */
 private function buildForm(FormInterface $form, $data)
 {
     $form->remove('value')->remove('from')->remove('to');
     if ($data === null || in_array($data, NumberFilter::getSimpleTypes(), true)) {
         $form->add('value', NumberForm::class);
     } elseif (in_array($data, NumberFilter::getCompoundTypes())) {
         $form->add('from', NumberForm::class)->add('to', NumberForm::class);
     }
 }
 /**
  * @param FormInterface $form
  * @param string|null   $data
  */
 private function buildForm(FormInterface $form, $data)
 {
     $form->remove('value')->remove('from')->remove('to');
     if ($data === null || in_array($data, DateTimeFilter::getSimpleTypes(), true)) {
         $form->add('value', $this->innerType);
     } elseif (in_array($data, DateTimeFilter::getCompoundTypes())) {
         $form->add('from', $this->innerType)->add('to', $this->innerType);
     }
 }
 /**
  * @param FormInterface $form
  */
 protected function replaceOwnerField(FormInterface $form)
 {
     if ($this->isAssignGranted) {
         return;
     }
     $owner = $form->get($this->fieldName)->getData();
     $ownerData = method_exists($owner, 'getName') ? $owner->getName() : (string) $owner;
     $form->remove($this->fieldName);
     $form->add($this->fieldName, 'text', array('disabled' => true, 'data' => $ownerData ?: '', 'mapped' => false, 'required' => false, 'label' => $this->fieldLabel));
 }
 protected function manageCoverRelativeFields(FormInterface $form, $isCover)
 {
     switch ($isCover) {
         case true:
             $form->remove('alt')->remove('title')->remove('legend')->remove('width')->add('height', null, array('label' => 'widget_image.form.minHeight.label', 'vic_help_label' => 'widget_image.form.height.help_label'))->remove('link')->remove('asynchronous')->remove('lazyLoad');
             break;
         default:
             $form->add('alt', null, array('label' => 'widget_image.form.alt.label', 'vic_help_label' => 'widget_image.form.alt.help_label'))->add('title', null, array('label' => 'widget_image.form.title.label'))->add('legend', null, array('label' => 'widget_image.form.legend.label'))->add('width', null, array('label' => 'widget_image.form.width.label', 'vic_help_label' => 'widget_image.form.width.help_label'))->add('height', null, array('label' => 'widget_image.form.height.label', 'vic_help_label' => 'widget_image.form.width.help_label'))->add('link', 'victoire_link')->add('lazyLoad', null, array('label' => 'widget_image.form.lazyLoad.label', 'vic_help_label' => 'widget_image.form.lazyLoad.help_label', 'required' => false))->add('asynchronous', null, array('label' => 'victoire.widget.type.asynchronous.label', 'required' => false));
             break;
     }
 }
 /**
  * @param array $rawData
  * @param FormInterface $form
  *
  * @return CustomerInterface|null
  */
 protected function getCustomerFromProperSource(array $rawData, FormInterface $form)
 {
     if (null !== ($customer = $this->customerContext->getCustomer())) {
         $form->remove('email');
         return $customer;
     }
     if (!isset($rawData['email'])) {
         return null;
     }
     return $this->createCustomerIfNecessary($rawData['email']);
 }
 /**
  * {@inheritdoc}
  */
 protected function updateAvailableUnits(FormInterface $form)
 {
     /** @var OrderLineItem $item */
     $item = $form->getData();
     if (!$item->getProduct()) {
         return;
     }
     $form->remove('productUnit');
     $form->add('productUnit', ProductUnitSelectionType::NAME, ['label' => 'orob2b.product.productunit.entity_label', 'required' => true, 'query_builder' => function (ProductUnitRepository $er) use($item) {
         return $er->getProductUnitsQueryBuilder($item->getProduct());
     }]);
 }
Beispiel #12
0
 public function addElements_Prof_Matiere(FormInterface $form, Matiere $matiere = null)
 {
     $submit = $form->get('ajouter');
     $form->remove('ajouter');
     $form->add('matiere', EntityType::class, ['class' => 'EDTBundle:Matiere', 'choice_label' => 'nom', 'placeholder' => '-- choisir une matière --', 'multiple' => false, 'mapped' => true, 'data' => $matiere]);
     $profs = array();
     if ($matiere) {
         $repo = $this->em->getRepository('UserBundle:Professeur');
         $profs = $repo->createQueryBuilder('p')->leftJoin('p.prof_matieres', 'pm')->addSelect('pm')->leftJoin('pm.matiere', 'm')->addSelect('m')->where('m.id = :id_m')->setParameter('id_m', $matiere->getId())->getQuery()->getResult();
     }
     $form->add('professeur', EntityType::class, ['class' => 'UserBundle:Professeur', 'choice_label' => 'username', 'placeholder' => '--choisir une matière en premier --', 'choices' => $profs, 'multiple' => false]);
     $form->add($submit);
 }
 /**
  * @param FormInterface $form
  * @param string|null   $data
  */
 private function buildForm(FormInterface $form, $data)
 {
     $form->remove('value');
     if ($data === null || in_array($data, ResourceType::getSimpleTypes(), true)) {
         $filter = $form->getConfig()->getOption('filter');
         if ($filter->hasOption('form')) {
             $resourceForm = $filter->getOption('form');
         } else {
             $resource = $filter->hasOption('resource') ? $filter->getOption('resource') : $filter->getName();
             $resourceForm = $this->resourceRegistry[$resource]->getChoiceForm();
         }
         $form->add('value', $resourceForm);
     }
 }
 /**
  * @param FieldTypeInterface        $data
  * @param string                    $type
  * @param FormInterface             $form
  */
 protected function addDefaultValueField(FieldTypeInterface $data, $type, FormInterface $form)
 {
     if ($form->has('default_value')) {
         $form->remove('default_value');
     }
     if (is_null($type) || !array_key_exists($type, $this->options)) {
         return;
     }
     if ($data->getType() !== $type) {
         $data->setDefaultValue(null);
     }
     if (isset($this->options[$type]['default_value'])) {
         $defaultValueField = $this->options[$type]['default_value'];
         $defaultOption = isset($defaultValueField['options']) ? $defaultValueField['options'] : array();
         $form->add('default_value', $defaultValueField['type'], $defaultOption);
     }
 }
Beispiel #15
0
 protected function addElements(FormInterface $form, Province $province = null)
 {
     // Remove the submit button, we will place this at the end of the form later
     $submit = $form->get('save');
     $form->remove('save');
     // Add the province element
     $form->add('province', 'entity', array('data' => $province, 'empty_value' => '-- Choose --', 'class' => 'RubricaBundle:Provinceb', 'mapped' => false));
     // Cities are empty, unless we actually supplied a province
     $cities = array();
     if ($province) {
         // Fetch the cities from specified province
         $repo = $this->em->getRepository('RubricaBundle:City');
         $cities = $repo->findByProvince($province, array('name' => 'asc'));
     }
     // Add the city element
     $form->add('city', 'entity', array('empty_value' => '-- Select a province first --', 'class' => 'RubricaBundle:City', 'choices' => $cities));
     // Add submit button again, this time, it's back at the end of the form
     $form->add($submit);
 }
 /**
  * @param FormInterface $form
  * @param mixed $precision
  * @param bool $force
  */
 protected function addQuantity(FormInterface $form, $precision, $force = false)
 {
     if ($force && $form->has('quantity')) {
         $form->remove('quantity');
     }
     $form->add('quantity', 'number', ['label' => 'orob2b.pricing.quantity.label', 'precision' => $precision, 'constraints' => [new NotBlank(), new Range(['min' => 0]), new Decimal()]]);
 }
 /**
  * @param TransportInterface $selectedTransport
  * @param FormInterface $form
  */
 protected function addTransportSettingsForm(TransportInterface $selectedTransport, FormInterface $form)
 {
     if ($selectedTransport) {
         $transportSettingsFormType = $selectedTransport->getSettingsFormType();
         if ($transportSettingsFormType) {
             $form->add('transportSettings', $transportSettingsFormType, ['required' => true]);
         } elseif ($form->has('transportSettings')) {
             $form->remove('transportSettings');
         }
     }
 }
 private function removeFormFields(FormInterface $form)
 {
     if ($this->allowDelete) {
         foreach ($form as $name => $child) {
             if (!isset($data[$name])) {
                 $form->remove($name);
             }
         }
     }
 }
 /**
  * Adds user default owner field to form.
  *
  * @param FormInterface $form
  */
 protected function addBusinessUnitField(FormInterface $form)
 {
     if ($form->has('defaultUserOwner')) {
         $form->remove('defaultUserOwner');
     }
     if (!$form->has('defaultBusinessUnitOwner')) {
         $form->add('defaultBusinessUnitOwner', 'oro_business_unit_select', ['required' => true, 'label' => 'oro.integration.integration.default_business_unit_owner.label', 'tooltip' => 'oro.integration.integration.default_business_unit_owner.description', 'constraints' => [new NotNull()]]);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function updateAvailableUnits(FormInterface $form)
 {
     /** @var OrderLineItem $item */
     $item = $form->getData();
     if (!$item->getOrder()) {
         return;
     }
     if ($item->getProduct()) {
         $choices = $this->getProductAvailableChoices($item);
     } else {
         $choices = [$item->getProductUnit()];
     }
     $form->remove('productUnit');
     $form->add('productUnit', ProductUnitSelectionType::NAME, ['label' => 'orob2b.product.productunit.entity_label', 'required' => true, 'choices' => $choices]);
 }
Beispiel #21
0
 /**
  * @param FormInterface $form
  * @param Repository    $repository
  */
 protected function loadDataType(FormInterface $form, Repository $repository)
 {
     $formClass = 'SatisAdmin\\Form\\' . ucfirst($repository->getType()) . 'RepositoryType';
     $form->remove('data');
     $form->add('data', new $formClass(), ['virtual' => true, 'data_class' => get_class($repository)]);
 }
 /**
  * @param FormInterface $form
  * @param object[]      $choices
  */
 private function buildForm(FormInterface $form, array $choices)
 {
     $form->remove('value')->add('value', GridBatchValueType::class, ['choices' => $choices, 'grid' => $form->getConfig()->getOption('grid')]);
 }
Beispiel #23
0
 /**
  * @param string $responsiveKey
  */
 private function generateBackgroundFields(FormInterface $form, $responsiveKey, $type = null)
 {
     /*
      * Build the part of form as the good type
      * Exemple: XS will have background color field whereas SM will have background image field
      */
     if ($type == 'image') {
         $form->remove('containerBackgroundColor' . $responsiveKey)->add('containerBackgroundImage' . $responsiveKey, MediaType::class, ['label' => 'widget_layout.form.containerBackgroundImage' . $responsiveKey . '.label'])->add('containerBackgroundRepeat' . $responsiveKey, ChoiceType::class, ['label' => 'widget_layout.form.containerBackgroundRepeat' . $responsiveKey . '.label', 'choices' => ['widget_layout.form.containerBackgroundRepeat.choices.noRepeat.label' => 'no-repeat', 'widget_layout.form.containerBackgroundRepeat.choices.repeat.label' => 'repeat', 'widget_layout.form.containerBackgroundRepeat.choices.repeatX.label' => 'repeat-x', 'widget_layout.form.containerBackgroundRepeat.choices.repeatY.label' => 'repeat-y'], 'choices_as_values' => true])->add('containerBackgroundPosition' . $responsiveKey, ChoiceType::class, ['label' => 'widget_layout.form.containerBackgroundPosition' . $responsiveKey . '.label', 'choices' => ['widget_layout.form.containerBackgroundRepeat.choices.center.center.label' => 'center center', 'widget_layout.form.containerBackgroundRepeat.choices.center.right.label' => 'center right', 'widget_layout.form.containerBackgroundRepeat.choices.center.left.label' => 'center left', 'widget_layout.form.containerBackgroundRepeat.choices.top.center.label' => 'top center', 'widget_layout.form.containerBackgroundRepeat.choices.top.right.label' => 'top right', 'widget_layout.form.containerBackgroundRepeat.choices.top.left.label' => 'top left', 'widget_layout.form.containerBackgroundRepeat.choices.bottom.center.label' => 'bottom center', 'widget_layout.form.containerBackgroundRepeat.choices.bottom.right.label' => 'bottom right', 'widget_layout.form.containerBackgroundRepeat.choices.bottom.left.label' => 'bottom left'], 'choices_as_values' => true])->add('containerBackgroundSize' . $responsiveKey, null, ['label' => 'widget_layout.form.containerBackgroundSize' . $responsiveKey . '.label', 'attr' => ['placeholder' => 'widget_layout.form.containerWidth.placeholder']])->add('containerBackgroundOverlay' . $responsiveKey, null, ['label' => 'widget_layout.form.containerBackgroundOverlay' . $responsiveKey . '.label', 'attr' => ['placeholder' => 'widget_layout.form.containerBackgroundOverlay.placeholder']]);
     } else {
         $form->remove('containerBackgroundImage' . $responsiveKey)->remove('containerBackgroundRepeat' . $responsiveKey)->remove('containerBackgroundPosition' . $responsiveKey)->remove('containerBackgroundSize' . $responsiveKey)->remove('containerBackgroundOverlay' . $responsiveKey)->add('containerBackgroundColor' . $responsiveKey, null, ['label' => 'widget_layout.form.containerBackgroundColor' . $responsiveKey . '.label', 'attr' => ['placeholder' => 'widget_layout.form.containerBackgroundColor.placeholder']]);
     }
 }
Beispiel #24
0
 /**
  * @param \Symfony\Component\Form\FormInterface|null $form
  */
 protected function manageTemplate($blog_id, $form)
 {
     $articleTemplateRepo = $this->entityManager->getRepository('VictoireBlogBundle:ArticleTemplate');
     if (!$form->getData()->getTemplate()) {
         if ($articleTemplateRepo->filterByBlog($blog_id)->getCount('parent')->run('getSingleScalarResult') > 1) {
             $articleTemplates = function (ArticleTemplateRepository $repo) use($blog_id) {
                 return $repo->filterByBlog($blog_id)->getInstance();
             };
             $form->add('template', null, ['label' => 'form.article.type.template.label', 'property' => 'backendName', 'required' => true, 'query_builder' => $articleTemplates]);
         } else {
             $form->add('template', 'victoire_article_template_type', ['data_class' => null, 'data' => $articleTemplateRepo->filterByBlog($blog_id)->run('getSingleResult')]);
         }
     } else {
         $form->remove('template');
     }
 }
 private function setEndDateStopMethod(FormInterface $form)
 {
     $tomorrow = new \DateTime('now');
     $tomorrow->modify('+1 day');
     $form->remove('iterations')->add('endDate', null, array('widget' => 'single_text', 'format' => 'dd MMM yyyy', 'html5' => false, 'required' => false, 'label' => false, 'empty_data' => $tomorrow->format('d m Y')));
 }
Beispiel #26
0
 /**
  * @param \Symfony\Component\Form\FormInterface $form
  * @param array $data
  *
  * @return void
  */
 protected function addCalculatorPluginAmountValidators(FormInterface $form, array $data)
 {
     if (empty($data[self::FIELD_CALCULATOR_PLUGIN])) {
         return;
     }
     $calculatorPlugin = $this->getCalculatorPlugin($data[self::FIELD_CALCULATOR_PLUGIN]);
     if (!$calculatorPlugin) {
         return;
     }
     $amountField = $form->get(self::FIELD_AMOUNT);
     $constraints = $amountField->getConfig()->getOption('constraints');
     $constraints = array_merge($constraints, $calculatorPlugin->getAmountValidators());
     $form->remove(self::FIELD_AMOUNT);
     $this->addAmountField($form, ['constraints' => $constraints]);
 }
 /**
  * @param FormInterface $form
  * @param array $options
  */
 protected function disableNewEntityValidation(FormInterface $form, array $options)
 {
     // disable all validation for new entity field
     $form->remove('new_entity');
     $form->add('new_entity', $options['create_entity_form_type'], array_merge($this->getNewEntityFormOptions($options), array('validation_groups' => false)));
 }
 /**
  * Update form fields by group
  *
  * @param FormInterface $form
  * @param $group
  * @param null $financialInstitution
  */
 private function updateFieldsByGroup(FormInterface $form, $group, $financialInstitution = null)
 {
     switch ($group) {
         case AccountGroup::GROUP_DEPOSIT_MONEY:
             if ($form->has('financial_institution')) {
                 $form->remove('financial_institution');
             }
             break;
         case AccountGroup::GROUP_OLD_EMPLOYER_RETIREMENT:
             $form->add($this->factory->createNamed('financial_institution', 'text', null, array('label' => 'Former Employer')));
             break;
         case AccountGroup::GROUP_EMPLOYER_RETIREMENT:
             if ($financialInstitution) {
                 $employerFinancialInstitution = explode('(', $financialInstitution);
                 $provider = trim($employerFinancialInstitution[0]);
                 $company = trim($employerFinancialInstitution[1], ' )');
             } else {
                 $provider = null;
                 $company = null;
             }
             $form->add($this->factory->createNamed('financial_institution', 'text', null, array('label' => 'Employer Name', 'data' => $company)))->add($this->factory->createNamed('plan_provider', 'text', null, array('label' => 'Retirement Plan Provide', 'property_path' => false, 'data' => $provider)));
             break;
         case AccountGroup::GROUP_FINANCIAL_INSTITUTION:
             //$group = AccountGroup::GROUP_FINANCIAL_INSTITUTION;
             $form->add($this->factory->createNamed('financial_institution', 'text', null, array('label' => 'Financial Institution')))->add($this->factory->createNamed('transferInformation', new AccountTransferInformationFormType($this->em), null, array('label' => ' ')));
             break;
         default:
             $group = AccountGroup::GROUP_DEPOSIT_MONEY;
             if ($form->has('financial_institution')) {
                 $form->remove('financial_institution');
             }
             break;
     }
     $this->updateGroupTypeField($form, $group);
 }