Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // Add the default form fields
     $builder->add('title', 'text', ['label' => $this->translator->trans('form.title'), 'attr' => ['placeholder' => $this->translator->trans('content.form.title.placeholder')]])->add('description', 'text', ['label' => $this->translator->trans('form.description'), 'attr' => ['placeholder' => $this->translator->trans('content.form.description.placeholder')]])->add('slug', 'slug', ['attr' => ['placeholder' => $this->translator->trans('content.form.slug.placeholder'), 'help_text' => $this->translator->trans('form.slug.help_text')]])->add('directory', 'entity', ['class' => 'OpiferCmsBundle:Directory', 'property' => 'name', 'empty_value' => '/', 'required' => false, 'empty_data' => null, 'attr' => ['help_text' => $this->translator->trans('content.form.directory.help_text')]])->add('valueset', new ValueSetType());
     // Add advanced fields only on the advanced option page.
     if ($options['mode'] == 'advanced') {
         $builder->add('realPresentation', 'presentationeditor', ['label' => $this->translator->trans('form.presentation'), 'attr' => ['align_with_widget' => true]]);
     }
     $builder->add('save', 'submit', ['label' => $this->translator->trans('content.form.submit')]);
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $content = $builder->getData();
     $transformer = new SlugTransformer();
     // Add the default form fields
     $builder->add('title', 'text', ['label' => $this->translator->trans('form.title'), 'attr' => ['placeholder' => $this->translator->trans('content.form.title.placeholder'), 'help_text' => $this->translator->trans('content.form.title.help_text')]])->add('description', 'text', ['label' => $this->translator->trans('form.description'), 'attr' => ['placeholder' => $this->translator->trans('content.form.description.placeholder'), 'help_text' => $this->translator->trans('content.form.description.help_text')]])->add($builder->create('slug', 'text', ['attr' => ['placeholder' => $this->translator->trans('content.form.slug.placeholder'), 'help_text' => $this->translator->trans('form.slug.help_text')]])->addViewTransformer($transformer))->add('directory', 'entity', ['class' => $this->directoryClass, 'query_builder' => function ($er) {
         return $er->createQueryBuilder('d')->orderBy('d.root', 'ASC')->addOrderBy('d.lft', 'ASC');
     }, 'property' => 'slug', 'empty_value' => '/', 'required' => false, 'empty_data' => null, 'attr' => ['help_text' => $this->translator->trans('content.form.directory.help_text')]])->add('alias', 'text', ['attr' => ['help_text' => $this->translator->trans('content.form.alias.help_text'), 'widget_col' => 4]])->add('symlink', 'contentpicker', ['label' => $this->translator->trans('form.symlink')])->add('active', 'checkbox');
     $builder->add('valueset', 'opifer_valueset', ['attr' => ['class' => $content->getSymlink() ? 'hidden' : '']]);
     // Add advanced fields only on the advanced option page.
     if ($options['mode'] == 'advanced') {
         $builder->add('realPresentation', 'presentationeditor', ['label' => $this->translator->trans('form.presentation'), 'attr' => ['align_with_widget' => true]]);
     }
     $builder->add('save', 'submit', ['label' => $this->translator->trans('content.form.submit')]);
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('displayName', 'text', ['label' => $this->translator->trans('template.display_name'), 'attr' => ['class' => 'slugify', 'data-slugify-target' => '.slugify-target', 'data-slugify-separator' => '_', 'placeholder' => $this->translator->trans('form.display_name.placeholder'), 'help_text' => $this->translator->trans('form.display_name.help_text')]])->add('name', 'text', ['label' => $this->translator->trans('template.name'), 'attr' => ['class' => 'slugify-target', 'placeholder' => $this->translator->trans('form.name.placeholder'), 'help_text' => $this->translator->trans('form.name.help_text')]])->add('object_class', 'template_object_class', ['label' => $this->translator->trans('template.object_class'), 'attr' => ['help_text' => $this->translator->trans('form.object_class.help_text')]])->add('presentation', 'presentationeditor', ['label' => $this->translator->trans('template.presentation'), 'attr' => ['help_text' => $this->translator->trans('form.presentation.help_text')]])->add('attributes', 'bootstrap_collection', ['allow_add' => true, 'allow_delete' => true, 'type' => $this->attributeType])->add('save', 'submit', ['label' => ucfirst($this->translator->trans('form.submit'))]);
 }
 /**
  * {@inheritDoc}
  *
  * The error_bubbling is set to false so we can render the hidden field errors ourselves
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('street', 'hidden', ['error_bubbling' => false, 'constraints' => [new NotBlank(['message' => $this->translator->trans('form.google_address.street.not_blank')]), new Regex(['pattern' => '/(\\d+)/', 'message' => $this->translator->trans('form.google_address.street.no_digit')])]])->add('zipcode', 'hidden', ['error_bubbling' => false, 'constraints' => [new NotBlank(['message' => $this->translator->trans('form.google_address.zipcode.not_blank')])]])->add('city', 'hidden', ['error_bubbling' => false, 'constraints' => [new NotBlank(['message' => $this->translator->trans('form.google_address.city.not_blank')])]])->add('country', 'hidden', ['error_bubbling' => false, 'constraints' => [new NotBlank(['message' => $this->translator->trans('form.google_address.country.not_blank')])]])->add('lat', 'hidden', ['error_bubbling' => false, 'constraints' => [new NotBlank(['message' => $this->translator->trans('form.google_address.lat.not_blank')])]])->add('lng', 'hidden', ['error_bubbling' => false, 'constraints' => [new NotBlank(['message' => $this->translator->trans('form.google_address.lng.not_blank')])]]);
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['label' => $this->translator->trans('form.slug.label'), 'attr' => ['help_text' => $this->translator->trans('form.slug.help_text')]]);
 }
Esempio n. 6
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('site', 'entity', ['class' => 'OpiferCmsBundle:Site', 'property' => 'name', 'attr' => ['help_text' => $this->translator->trans('content.form.site.help_text')]])->add('template', 'entity', ['class' => 'OpiferEavBundle:Template', 'property' => 'name', 'attr' => ['help_text' => $this->translator->trans('content.form.template.help_text', ['%url%' => $this->router->generate('opifer.crud.new', ['slug' => 'templates'])])]])->add('locale', 'locale', ['choices' => $this->locales, 'attr' => ['help_text' => $this->translator->trans('content.form.locale.help_text')]])->add('save', 'submit', ['label' => ucfirst($this->translator->trans('content.form.init.submit'))]);
 }
Esempio n. 7
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('valueType', 'value_provider', ['label' => $this->translator->trans('attribute.value_type'), 'attr' => ['placeholder' => $this->translator->trans('form.value_type.placeholder'), 'help_text' => $this->translator->trans('form.value_type.help_text')]])->add('displayName', 'text', ['label' => $this->translator->trans('attribute.display_name'), 'attr' => ['class' => 'slugify', 'data-slugify-target' => '.slugify-target-' . $builder->getName(), 'data-slugify-separator' => '_', 'placeholder' => $this->translator->trans('form.display_name.placeholder'), 'help_text' => $this->translator->trans('form.display_name.help_text'), 'widget_col' => 6]])->add('name', 'text', ['label' => $this->translator->trans('attribute.name'), 'attr' => ['class' => 'slugify-target-' . $builder->getName(), 'placeholder' => $this->translator->trans('form.name.placeholder'), 'help_text' => $this->translator->trans('form.name.help_text'), 'widget_col' => 6]])->add('description', 'text', ['label' => $this->translator->trans('attribute.description'), 'attr' => ['help_text' => $this->translator->trans('form.description.help_text')]])->add('sort', 'integer', ['label' => $this->translator->trans('attribute.sort'), 'attr' => ['help_text' => $this->translator->trans('form.sort.help_text'), 'widget_col' => 2]]);
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         $attribute = $event->getData();
         $form = $event->getForm();
         if ($attribute && in_array($attribute->getValueType(), ['checklist', 'select', 'radio'])) {
             $form->add('options', 'collapsible_collection', ['allow_add' => true, 'allow_delete' => true, 'type' => $this->optionType]);
         }
         if ($attribute && $attribute->getValueType() == 'nested') {
             $form->add('allowedTemplates', 'entity', ['class' => $this->templateClass, 'property' => 'displayName', 'query_builder' => function (EntityRepository $er) {
                 return $er->createQueryBuilder('t')->orderBy('t.displayName', 'ASC');
             }, 'by_reference' => false, 'expanded' => true, 'multiple' => true, 'label' => $this->translator->trans('attribute.allowed_templates'), 'attr' => ['help_text' => $this->translator->trans('form.allowed_templates.help_text')]]);
         }
     });
 }