Last active
April 26, 2019 07:41
-
-
Save ger86/76c0b51edd9cf6d7d8deced9a0a56eec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Form\Type; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\OptionsResolver\OptionsResolver; | |
use Symfony\Component\Routing\RouterInterface; | |
use App\Model\Person; | |
use App\Form\Type\Select2Type; | |
class PersonFormType extends AbstractType { | |
public function __construct(RouterInterface $router) { | |
$this->router = $router; | |
} | |
public function buildForm(FormBuilderInterface $builder, array $options) { | |
$builder | |
->add('job', Select2Type::class, [ | |
'label' => '¿Cuál es tu profesión?', | |
'required' => true, | |
'attr' => ['data-autocomplete-url' => $this->router->generate('search_jobs')], | |
'choices' => [] | |
]) | |
->add('submit', SubmitType::class, [ | |
'label' => 'Enviar', | |
'attr' => ['class' => 'btn-primary btn-submit'] | |
]); | |
} | |
public function configureOptions(OptionsResolver $resolver) | |
{ | |
$resolver->setDefaults(['data_class' => Person::class]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment