Exemplo n.º 1
0
 /**
  * build form
  * @param FormBuilderInterface $builder bulder object
  * @param array                $options available options to inject
  *
  * @see \Symfony\Component\Form\AbstractType::buildForm()
  *
  * @return void
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('translations', 'a2lix_translations_gedmo', array('locales' => $this->locales, 'fields' => array('title' => array('required' => false, 'label' => 'Title', 'field_type' => TextType::class, 'constraints' => array(new VALIDATOR\NotBlank(), new VALIDATOR\Length(array('max' => 150))), 'attr' => array('oninvalid' => "setCustomValidity('" . 'Please fill in this value.' . "')", 'onfocus' => 'setCustomValidity(\'\')')), 'shortDesc' => array('required' => false, 'field_type' => TextareaType::class, 'label' => 'Short description', 'constraints' => array(new VALIDATOR\NotBlank()), 'attr' => array('oninvalid' => "setCustomValidity(\n                                                                                                                            '" . $this->container->get('translator')->trans('Please fill in this value', array(), 'messages') . "')", 'onfocus' => "setCustomValidity('')", 'class' => 'tinymce', 'data-theme' => 'advanced')), 'description' => array('field_type' => TextareaType::class, 'constraints' => array(new VALIDATOR\NotBlank()), 'attr' => array('oninvalid' => "setCustomValidity(\n                                                                                                                            '" . $this->container->get('translator')->trans('Please fill in this value', array(), 'messages') . "')", 'onfocus' => "setCustomValidity('')", 'class' => 'tinymce', 'data-theme' => 'advanced')))));
     $object = isset($options['data']) ? $options['data'] : null;
     $builder->add('publishedAt', 'date', array('required' => false, 'attr' => array('id' => 'published_at'), 'format' => 'yyyy-MM-dd', 'data' => isset($object) ? $object->getPublishedAt() ? $object->getPublishedAt() : new \DateTime() : new \DateTime(), 'widget' => 'single_text', 'read_only' => true));
     $builder->add('status', ChoiceType::class, array('choices' => News::getStatusOptions(), 'expanded' => true, 'multiple' => false, 'data' => isset($object) ? $object->getStatus() ? $object->getStatus() : 'A' : 'A', 'attr' => array('class' => 'minimal display-inline')));
     //$builder->add('logo', 'file', array('required' => false, 'label' => 'Image'));
     $builder->add('logo', 'file', array('required' => false, 'label' => 'Image', 'constraints' => array(new VALIDATOR\File(array('mimeTypes' => array('image/jpg', 'image/jpeg', 'image/png', 'image/bmp', 'image/gif'), 'mimeTypesMessage' => "Please Upload Valid File")))));
     $builder->add('updatedAt', 'hidden', array('data' => ''));
 }
 /**
  * build form
  * @param FormBuilderInterface $builder bulder object
  * @param array                $options available options to inject
  *
  * @see \Symfony\Component\Form\AbstractType::buildForm()
  *
  * @return void
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('search', TextType::class, array('mapped' => false, 'required' => false));
     $builder->remove('translations');
     $builder->add('status', ChoiceType::class, array('choices' => News::getStatusOptions(), 'expanded' => false, 'multiple' => false, 'attr' => array('class' => 'minimal')));
 }