Skip to content

Instantly share code, notes, and snippets.

@JuanLuisGarciaBorrego
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JuanLuisGarciaBorrego/85f2a38bef020ee8fa87 to your computer and use it in GitHub Desktop.
Save JuanLuisGarciaBorrego/85f2a38bef020ee8fa87 to your computer and use it in GitHub Desktop.
TaskType-eventsubscriber.php
<?php
namespace JuanLuis\LabBundle\Form\Type;
use JuanLuis\LabBundle\Form\EventListener\AddNameFieldOnlyForCreateNewTaskSubscriber;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TaskType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
//Llamamos a nuestra clase Subscriber
$builder->addEventSubscriber(new AddNameFieldOnlyForCreateNewTaskSubscriber());
$builder
->add('description');
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'JuanLuis\LabBundle\Entity\Task'
));
}
public function getName()
{
return 'Task';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment