• Fabien Potencier's avatar
    feature #1309 add a namedForm() method in FormTrait (quazardous) · 5b875899
    Fabien Potencier authored
    This PR was squashed before being merged into the 2.0.x-dev branch (closes #1309).
    
    Discussion
    ----------
    
    add a namedForm() method in FormTrait
    
    I do prefer using the namedForm builder.
    
    Just add the `$this['form.factory']->createNamedBuilder(...)` in `Silex\Application\FormTrait`:
    
    ```php
        /**
         * Creates and returns a named form builder instance.
         *
         * @param string                   $name
         * @param mixed                    $data    The initial data for the form
         * @param array                    $options Options for the form
         * @param string|FormTypeInterface $type    Type of the form
         *
         * @return \Symfony\Component\Form\FormBuilder
         */
        public function namedForm($name, $data = null, array $options = array(), $type = null)
        {
            if (null === $type) {
                // BC with Symfony < 2.8
                $type = class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form';
            }
    
            return $this['form.factory']->createNamedBuilder($name, $type, $data, $options);
        }
    ```
    
    Commits
    -------
    
    c8e61fc2 add a namedForm() method in FormTrait
    5b875899
Name
Last commit
Last update
bin Loading commit data...
doc Loading commit data...
src/Silex Loading commit data...
tests/Silex/Tests Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
LICENSE Loading commit data...
README.rst Loading commit data...
composer.json Loading commit data...
phpunit.xml.dist Loading commit data...