What are your best practices when developing Symfony 1.4 forms / widgets / validators?

I'm currently working on customizing a Symfony form, which includes writing widgets or, especially, extending existing ones.

However, this turned out to be much more complicated, because I thought that the functionality for checking, creating elements, saving objects, dynamic javascripts, etc. seems to be scattered everywhere. The many custom widgets that you can find are hard to extend, as they often do not share javascript, not HTML.

So what should be the guidelines for form / widget development?

I would like to summarize such recommendations. Only now I'm not too sure how they can look. Let's brainstorm together!

Separate HTML from PHP Put Javascript in additional files (non-intrusiveness) Don't overlay CSS styles on others. Do not write giant methods, but small extensible / overloadable .. What do you think should be included?

The original article can be found here: http://test.ical.ly/2010/08/25/question-what-would-you-expect-of-a-best-practice-document-when-developing-symfony-1- 4-form-widgets /

+4
source share
1 answer

Among the others mentioned in the article, do not code the identifiers and attributes of the form element in javascript.

<script type="text/javascript"> var widget_id = "<?php echo $form['widget']->renderId() ?>"; var widget_name = "<?php echo $form['widget']->renderName() ?>"; </script> 
+1
source

All Articles