Created
January 24, 2018 16:03
-
-
Save ollo-ride-nico/6ed798648a86e7bb16aa05332f16e700 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
class TricksType extends AbstractType | |
{ | |
private $entitymanager; | |
public function __construct(EntityManagerInterface $entityManager) | |
{ | |
$this->entitymanager = $entityManager; | |
} | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
// On affiche les champs du builder | |
$builder | |
->add('nom', TextType::class) | |
->add('description', TextareaType::class) | |
->add('groupe', GroupeAddType::class) | |
->add('image', CollectionType::class, array( | |
'entry_type' => ImageAddType::class, | |
'entry_options' => array('data_class' => Image::class, 'label' => false), | |
'allow_add' => true, | |
'allow_delete' => true, | |
'by_reference' => false, | |
/*'mapped' => false,*/ | |
)); | |
} | |
public function configureOptions(OptionsResolver $resolver) | |
{ | |
$resolver->setDefaults(array( | |
'data_class' => Tricks::class | |
)); | |
} | |
} | |
class ImageAddType extends AbstractType | |
{ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder | |
->add('alt', TextType::class, array('label' => 'Mot clefs(alt)')) | |
->add('url', FileType::class, array('label' => 'Ajouter une image:', | |
)); | |
} | |
public function configureOptions(OptionsResolver $resolver) | |
{ | |
$resolver->setDefaults(array( | |
'data_class' => Image::class, | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment