ElementAddForm.php 853B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Muzich\CoreBundle\Form\Element;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\FormBuilder;
  5. class ElementAddForm extends AbstractType
  6. {
  7. public function buildForm(FormBuilder $builder, array $options)
  8. {
  9. $builder->add('name', 'text', array(
  10. 'required' => true,
  11. ));
  12. $builder->add('url', 'text', array(
  13. 'required' => true,
  14. ));
  15. $builder->add('tags', 'choice', array(
  16. 'choices' => $options['tags'],
  17. 'expanded' => true,
  18. 'multiple' => true
  19. ));
  20. }
  21. public function getName()
  22. {
  23. return 'element_add';
  24. }
  25. public function getDefaultOptions(array $options)
  26. {
  27. return array(
  28. 'name' => '',
  29. 'url' => '',
  30. 'tags' => array(),
  31. 'data_class' => 'Muzich\CoreBundle\Entity\Element'
  32. );
  33. }
  34. }