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 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);
     }
 }
Beispiel #3
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);
     }
 }
Beispiel #4
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);
 }
 /**
  * Update form fields
  *
  * @param FormInterface $form
  * @param null $data
  */
 private function update(FormInterface $form, $data)
 {
     if (!is_array($data) || !array_key_exists('owner_types', $data)) {
         return;
     }
     if ($this->isJoint) {
         $form->add($this->factory->createNamed('owner_types', 'choice', $data['owner_types'], array('mapped' => false, 'choices' => $this->getOwnerTypesChoices(), 'expanded' => true, 'multiple' => true, 'data' => $data['owner_types'])));
         if (is_array($data) && (array_key_exists('other_contact', $data) || in_array(ClientAccountOwner::OWNER_TYPE_OTHER, $data['owner_types']))) {
             $form->add($this->factory->createNamed('other_contact', new OtherAccountOwnerFormType($this->getOtherContactData())));
         }
     } else {
         $form->add($this->factory->createNamed('owner_types', 'choice', $data, array('mapped' => false, 'choices' => $this->getOwnerTypesChoices(), 'expanded' => true, 'multiple' => false, 'data' => $data)));
     }
 }
 /**
  * Adds filter fields to form.
  * 
  * @param FormInterface $form   The filter form.
  */
 private function addFilterFields(FormInterface $form)
 {
     $config = $this->getConfig($this->fieldName);
     $form->add('field', 'hidden', array('data' => $config['field']));
     $form->add('operator', 'choice', array('choices' => $this->getOperators($config['filter']), 'required' => true, 'translation_domain' => 'Admingenerator'));
     $isCollectionType = array_key_exists('type', $config['options']) && array_key_exists('options', $config['options']) && array_key_exists('prototype', $config['options']);
     if ($isCollectionType) {
         $formType = $config['options']['type'];
         $formOptions = $config['options']['options'];
     } else {
         $formType = $config['form'];
         $formOptions = $config['options'];
     }
     $form->add('value', $formType, array_merge($formOptions, array('required' => true)));
 }
 /**
  * Merges constraints from the form with constraints in the class metaData
  *
  * @param FormInterface $form
  */
 public function mergeConstraints(FormInterface &$form)
 {
     $metaData = null;
     $dataClass = $form->getConfig()->getDataClass();
     if ($dataClass != '') {
         $metaData = $this->validator->getMetadataFor($dataClass);
     }
     if ($metaData instanceof ClassMetadata) {
         /**
          * @var FormInterface $child
          */
         foreach ($form->all() as $child) {
             $options = $child->getConfig()->getOptions();
             $name = $child->getConfig()->getName();
             $type = $child->getConfig()->getType()->getName();
             if (isset($options['constraints'])) {
                 $existingConstraints = $options['constraints'];
                 $extractedConstraints = $this->extractPropertyConstraints($name, $metaData);
                 // Merge all constraints
                 $options['constraints'] = array_merge($existingConstraints, $extractedConstraints);
             }
             $form->add($name, $type, $options);
         }
     }
 }
 /**
  * Build form field
  *
  * @param DocumentType  $document      Document type
  * @param FormInterface $form          Form
  * @param string        $name          Field name
  * @param string        $type          Field type
  * @param array         $options       Options
  * @param mixed         $submittedData Submitted data
  * @return void
  */
 public function buildField(DocumentType $document, FormInterface $form, $name, $type, array $options = [], $submittedData = null)
 {
     $options['type'] = $document->getChildForm($options['options']['data_class']);
     $options['allow_add'] = true;
     $options['allow_delete'] = true;
     $form->add($name, $type, $options);
 }
Beispiel #9
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);
     }
 }
 private function addUniversityForm(FormInterface $form, $university)
 {
     $form->add($this->factory->createNamed('university', 'entity', $university, array('class' => 'AppBundle:University', 'mapped' => false, 'auto_initialize' => false, 'label' => 'label.university', 'placeholder' => 'placeholder.university', 'query_builder' => function (EntityRepository $repository) {
         $qb = $repository->createQueryBuilder('university')->orderBy('university.name', 'ASC');
         return $qb;
     })));
 }
 /**
  * @param FormInterface $form
  * @param string        $ruleType
  * @param array         $data
  */
 protected function addConfigurationFields(FormInterface $form, $ruleType, array $data = [])
 {
     /** @var RuleCheckerInterface $checker */
     $checker = $this->checkerRegistry->get($ruleType);
     $configurationField = $this->factory->createNamed('configuration', $checker->getConfigurationFormType(), $data, ['auto_initialize' => false]);
     $form->add($configurationField);
 }
Beispiel #12
0
 /**
  * Build form field
  *
  * @param DocumentType  $document      Document type
  * @param FormInterface $form          Form
  * @param string        $name          Field name
  * @param string        $type          Field type
  * @param array         $options       Options
  * @param mixed         $submittedData Submitted data
  * @return void
  */
 public function buildField(DocumentType $document, FormInterface $form, $name, $type, array $options = [], $submittedData = null)
 {
     if ('strictboolean' === $type) {
         $options['submitted_data'] = $submittedData;
     }
     $form->add($name, $type, $options);
 }
Beispiel #13
0
 protected function attached($presenter)
 {
     if ($presenter instanceof Presenter) {
         $this->form->add('_signal', 'Arachne\\Forms\\Extension\\Application\\Type\\SignalType', ['mapped' => false, 'data' => $this->lookupPath('Nette\\Application\\UI\\Presenter') . self::NAME_SEPARATOR . 'submit']);
     }
     parent::attached($presenter);
 }
 /**
  * Adds column and filters sub forms
  *
  * @param FormInterface        $form
  * @param FormFactoryInterface $factory
  * @param string|null          $entity
  */
 protected function addFields($form, $factory, $entity = null)
 {
     $config = $form->getConfig();
     $groupingColumnChoiceType = $config->getOption('grouping_column_choice_type');
     if ($groupingColumnChoiceType) {
         $form->add($factory->createNamed('grouping', 'oro_query_designer_grouping', null, array('mapped' => false, 'column_choice_type' => $groupingColumnChoiceType, 'entity' => $entity, 'auto_initialize' => false)));
     }
     $columnChoiceType = $config->getOption('column_column_choice_type');
     if ($columnChoiceType) {
         $form->add($factory->createNamed('column', 'oro_query_designer_column', null, array('mapped' => false, 'column_choice_type' => $columnChoiceType, 'entity' => $entity, 'auto_initialize' => false)));
     }
     $filterColumnChoiceType = $config->getOption('filter_column_choice_type');
     if ($filterColumnChoiceType) {
         $form->add($factory->createNamed('filter', 'oro_query_designer_filter', null, array('mapped' => false, 'column_choice_type' => $filterColumnChoiceType, 'entity' => $entity, 'auto_initialize' => false)));
     }
 }
 /**
  * @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');
     }
 }
 public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
 {
     $fieldDefinition = $data->fieldDefinition;
     $formConfig = $fieldForm->getConfig();
     $names = $fieldDefinition->getNames();
     $label = $fieldDefinition->getName($formConfig->getOption('languageCode')) ?: reset($names);
     $fieldForm->add($formConfig->getFormFactory()->createBuilder()->create('value', ChoiceType::class, ['required' => $fieldDefinition->isRequired, 'label' => $label, 'multiple' => $fieldDefinition->fieldSettings['isMultiple'], 'choices' => array_flip($fieldDefinition->fieldSettings['options']), 'choices_as_values' => true])->addModelTransformer($fieldDefinition->fieldSettings['isMultiple'] ? new MultiSelectionValueTransformer() : new SingleSelectionValueTransformer())->setAutoInitialize(false)->getForm());
 }
 /**
  * @param FormInterface $form
  * @param $country
  */
 private function addDiscretionarySpendingForm(FormInterface $form, $country)
 {
     $formOptions = ['class' => 'TSCYABundle:DiscretionarySpending', 'placeholder' => 'Choose an option', 'label' => 'Discretionary Spending', 'attr' => ['class' => 'discretionary_spending_selector select-select2'], 'query_builder' => function (EntityRepository $repository) use($country) {
         $qb = $repository->createQueryBuilder('ds')->join('ds.country', 'country')->where('country.id = :country')->setParameter('country', $country)->orderBy('ds.name', 'ASC');
         return $qb;
     }];
     $form->add($this->propertyPathToDiscretionarySpending, EntityType::class, $formOptions);
 }
 public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
 {
     $fieldDefinition = $data->fieldDefinition;
     $formConfig = $fieldForm->getConfig();
     $names = $fieldDefinition->getNames();
     $label = $fieldDefinition->getName($formConfig->getOption('languageCode')) ?: reset($names);
     $fieldForm->add($formConfig->getFormFactory()->createBuilder()->create('value', CheckboxType::class, ['required' => $fieldDefinition->isRequired, 'label' => $label])->addModelTransformer(new FieldValueTransformer($this->fieldTypeService->getFieldType($fieldDefinition->fieldTypeIdentifier)))->setAutoInitialize(false)->getForm());
 }
 /**
  * @param FormInterface $form
  * @param $course
  */
 private function addPromocionForm(FormInterface $form, $course)
 {
     $formOptions = ['class' => 'TS\\CYABundle\\Entity\\Promocion', 'required' => false, 'placeholder' => 'Choose an option', 'label' => 'Promocion', 'attr' => ['class' => 'promocion_selector select-select2'], 'query_builder' => function (EntityRepository $repository) use($course) {
         $qb = $repository->createQueryBuilder('promocion')->innerJoin('promocion.course', 'course')->where('course.id = :course_id')->setParameter('course_id', $course)->orderBy('promocion.name', 'ASC');
         return $qb;
     }];
     $form->add($this->propertyPathToPromocion, EntityType::class, $formOptions);
 }
 /**
  * @param FormInterface $form
  * @param $country
  */
 private function addCityForm(FormInterface $form, $country)
 {
     $formOptions = ['class' => 'TSCYABundle:City', 'placeholder' => 'Choose an option', 'required' => true, 'label' => 'City', 'attr' => ['class' => 'city_selector select-select2'], 'query_builder' => function (EntityRepository $repository) use($country) {
         $qb = $repository->createQueryBuilder('city')->where('city.country_id = :country')->setParameter('country', $country)->orderBy('city.name', 'ASC');
         return $qb;
     }];
     $form->add($this->propertyPathToCity, EntityType::class, $formOptions);
 }
 public function mapLimitationForm(FormInterface $form, Limitation $data)
 {
     $options = $this->getChoiceFieldOptions() + ['multiple' => true, 'label' => $data->getIdentifier(), 'required' => false];
     $choices = $this->getSelectionChoices();
     asort($choices, SORT_NATURAL | SORT_FLAG_CASE);
     $options += ['choices' => $choices];
     $form->add('limitationValues', 'choice', $options);
 }
 /**
  * @param \Ojs\LocationBundle\Entity\Country $country
  */
 private function addCountryForm(FormInterface $form, $country = null)
 {
     $formOptions = array('class' => 'Ojs\\LocationBundle\\Entity\\Country', 'mapped' => false, 'label' => 'Country', 'empty_value' => 'Select Country', 'attr' => array('class' => 'select2-element country_selector', 'data-province-source' => $this->provinceEndPoint));
     if ($country) {
         $formOptions['data'] = $country;
     }
     $form->add('country', 'entity', $formOptions);
 }
 private function addProvinceForm(FormInterface $form, $country_id)
 {
     $formOptions = array('class' => 'Ojs\\LocationBundle\\Entity\\Province', 'empty_value' => 'City', 'label' => 'City', 'attr' => array('class' => 'select2-element province_selector'), 'query_builder' => function (EntityRepository $repository) use($country_id) {
         $qb = $repository->createQueryBuilder('p')->innerJoin('p.country', 'country')->where('country.id = :country')->setParameter('country', $country_id);
         return $qb;
     });
     $form->add('city', 'entity', $formOptions);
 }
 /**
  * @param FormInterface $form
  * @param $headquarter
  */
 private function addExamForm(FormInterface $form, $headquarter)
 {
     $formOptions = ['class' => 'TS\\CYABundle\\Entity\\Exam', 'placeholder' => 'Choose an option', 'required' => true, 'label' => 'Exam', 'attr' => ['class' => 'exam_selector select-select2'], 'query_builder' => function (EntityRepository $repository) use($headquarter) {
         $qb = $repository->createQueryBuilder('exam')->innerJoin('exam.headquarter', 'headquarter')->where('headquarter.id = :headquarter_id')->setParameter('headquarter_id', $headquarter)->orderBy('exam.name', 'ASC');
         return $qb;
     }];
     $form->add($this->propertyPathToExam, EntityType::class, $formOptions);
 }
Beispiel #25
0
 public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data)
 {
     $editViewChoices = array();
     foreach ($this->availableEditViews as $editView) {
         $editViewChoices[$editView['identifier']] = $editView['name'];
     }
     $fieldDefinitionForm->add('subTreeLimit', 'integer', array('required' => false, 'property_path' => 'fieldSettings[subTreeLimit]', 'label' => 'field_definition.eztags.settings.subtree_limit', 'empty_data' => 0))->add('hideRootTag', 'checkbox', array('required' => false, 'property_path' => 'fieldSettings[hideRootTag]', 'label' => 'field_definition.eztags.settings.hide_root_tag'))->add('maxTags', 'integer', array('required' => false, 'property_path' => 'fieldSettings[maxTags]', 'label' => 'field_definition.eztags.settings.max_tags', 'empty_data' => 0, 'attr' => array('min' => 0)))->add('editView', 'choice', array('choices' => $editViewChoices, 'required' => true, 'property_path' => 'fieldSettings[editView]', 'label' => 'field_definition.eztags.settings.edit_view'));
 }
 public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data)
 {
     $fieldDefinitionForm->add('isMultiple', 'checkbox', ['required' => false, 'property_path' => 'fieldSettings[isMultiple]', 'label' => 'field_definition.ezcountry.is_multiple'])->add($fieldDefinitionForm->getConfig()->getFormFactory()->createBuilder()->create('defaultValue', 'choice', ['choice_list' => new ChoiceList(array_map(function ($country) {
         return $country['Alpha2'];
     }, $this->countriesInfo), array_map(function ($country) {
         return $country['Name'];
     }, $this->countriesInfo)), 'multiple' => true, 'expanded' => false, 'required' => false, 'label' => 'field_definition.ezcountry.default_value'])->addModelTransformer(new CountryValueTransformer($this->countriesInfo))->setAutoInitialize(false)->getForm());
 }
 /**
  * Build form field
  *
  * @param DocumentType  $document      Document type
  * @param FormInterface $form          Form
  * @param string        $name          Field name
  * @param string        $type          Field type
  * @param array         $options       Options
  * @param mixed         $submittedData Submitted data
  * @return void
  */
 public function buildField(DocumentType $document, FormInterface $form, $name, $type, array $options = [], $submittedData = null)
 {
     $options['allow_add'] = true;
     $options['allow_delete'] = true;
     $options['type'] = 'datetime';
     $options['options']['widget'] = 'single_text';
     $options['options']['input'] = 'datetime';
     $form->add($name, 'collection', $options);
 }
 /**
  * {@inheritdoc}
  */
 protected function addConfigurationFields(FormInterface $form, $registryIdentifier, array $data = [])
 {
     $model = $this->registry->get($registryIdentifier);
     $configuration = $model->getConfigurationFormType();
     if (null === $configuration) {
         return;
     }
     if (!$model instanceof ChannelBasedPromotionActionCommandInterface) {
         $form->add($this->createConfigurationField($configuration, $data));
         return;
     }
     $configurationCollection = $this->factory->createNamed('configuration', PromotionConfigurationType::class, [], ['compound' => true, 'auto_initialize' => false]);
     /** @var ChannelInterface $channel */
     foreach ($this->channelRepository->findAll() as $channel) {
         $configurationCollection->add($this->createConfigurationFieldForChannel($channel, $configuration, $data));
     }
     $form->add($configurationCollection);
 }
 /**
  * @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 #30
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);
 }