Closed Restless-ET closed 10 years ago
Passing javascript in YAML file.. which is read by PHP script.. and then outputted as HTML is really a bad idea. This means your JS code would go through 2 enviroments (yaml, php), so possibly It would have to be double-escaped.
Instead, I'd recommend (if you're useing Admingenerator) to use the getFormOption
function in your generated FormType PHP class see doc and write your JS code there.
This has two PROS:
If you want to escape the code (for JS) you may use the e4js
filter I wrote (in this bundle), read this SO question about how to use Twig Extension functions & filters in PHP.
Hi @loostro , thanks a lot for your feeback.
I knew from the start that this was a very raw solution so you're free to ignore this PR if you want. No hard feelings at all. :-) I do use Admingenerator and I've already used "getFormOption" in past but it didn't came to mind while I was doing this. :tired_face: I'll take a deeper look into this tomorrow while considering your suggestions since they really seem like a more robust approach for this. :+1: Thanks again.
@Restless-ET I'm closeing this PR becouse if we'd want to "configure JS scripts in YAML config", then we should create a generic solution (not a fix for one form type) and that PR would belong to Admingenerator project (since it's Admingenerator's code that "reads the YAML config" and sets the parameters for form types).
... on DatePickerType by passing an option on generator YAML file.
The idea behind this is to be able to pass on the generator.yml file something like this: