Symfony surcharge form

Par Alex_13, il y a 4 ans


Salut à tous !

J'utilise actuellement un bundle qui tourne sur plusieurs sites, sauf que sur un site en particulier j'aurais besoin d'ajouter d'autres champs dans un form particulier, mon bundle est dans le vendor, donc je ne le touche pas. J'aurais voulu savoir si il existait une soluce pour en plus des champs de base, ajouter d'autres champs via un fichier dans le dossier src/

Merci d'avance :)

4 réponses

Alex_13, il y a 4 ans

Pour ceux y seraient confrontés, voici la solution:

Créer un dossier Form dans le dossier src, et y inclure la méthode getParent qui return la class Form parente, et y ajouter dans la méthode buildForm les champs additionnels :)

ammys09, il y a 4 ans

As simple as the above example is, instead of building your application inside of app.js, we recommend Stimulus: a small JavaScript framework that makes it easy to attach behavior to HTML. It's powerful, and you will love it! Symfony even provides packages to add more features to Stimulus. These are called the Symfony UX Packages.

If you followed the setup instructions, you should already have Stimulus installed and ready to go! In fact, that's the purpose of the assets/bootstrap.js file: to initialize Stimulus and automatically load any "controllers" from the assets/controllers/ directory.