background preloader

Symfony2

Facebook Twitter

Packagist. CSV Export with Symfony 2. An example of Symfony2 CollectionType form field prototype on havvg's playground. While working an a multi-step form with multiple CollectionType in it, I came across the issue requiring a generic solution for handling allow_add and allow_delete on a collection. As there is no entry on the allow_delete part in the Symfony2 documentation itself, this solution may not be the best way to do it.

If you got other solutions on this topic, let me know! The form types <? Php namespace Acme\Bundle\BlogBundle\Form\Type; use Symfony\Component\Form\FormBuilder;use Symfony\Component\Form\AbstractType; class PostType extends AbstractType{ public function buildForm(FormBuilder $builder, array $options) { $builder ->add('title') ->add('content', 'textarea') ->add('tags', 'collection', array( 'type' => new TagType(), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_name' => 'tag__name__', 'options' => array( // options on the rendered TagTypes ), )) ; } public function getName() { return 'post'; }} <?

The prototype macro Example usage. Symfony2 form theme for Bootstrap - I Am Bot. Symfony/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig at master ยท symfony/symfony. Eclipse Symfony2. Symfony deployment Cheat Sheet. GetRaw escaping problems. Scene from "Disney's Adventures of the Gummi Bears" by Jymn Magon & Art Vitello (introduced in 1985) Probably most of us have encountered difficulties connected with default escaping mechanism in symfony templates.

Yes, it is frustrating at times. But there are solutions to handle that. single template solution Suppose we have a executeShow action in our frontend module. Then we have to add one line at the beginning of the showSuccess.php template file: $article = $sf_data->getRaw('article'); From this line, no data shall be escaped (and all formatting will be displayed properly). nested templates solution We can also have more complicated templates structure. Additionally, the indexSuccess.php file uses another template file: <?

We have to use the getRaw method IN ALL template/partial files. $articles = $sf_data->getRaw('articles'); And one line shall be added at the beginning of the _single.php partial file (the same as in the first example): Above solutions shall be sufficient in most cases. The Symfony2 Tutorial & Demo by Knp - KnpIpsum. YAML Builder | YAML based CSS layouts. Symfony2 Bundles. KnpBundles. Twig - The flexible, fast, and secure PHP template engine - Hands-on with the Symfony2 Framework. Symfony2 Eclipse Plugin - Installation.