2017 © Pedro Peláez
 

lib sf2-form-utils

buildForm() with objects instead of array

image

steevanb/sf2-form-utils

buildForm() with objects instead of array

  • Tuesday, May 31, 2016
  • by kujaff
  • Repository
  • 1 Watchers
  • 0 Stars
  • 386 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 23 Versions
  • 0 % Grown

The README.md

version php symfony Lines Total Downloads Scrutinizer, (*1)

symfony-form-options-builder

It helps you writing your Symfony FormType, with some traits and methods to add fields in buildForm() instead of array with some mysterious keys, and other stuff., (*2)

Installation, (*3)

Changelog, (*4)

Object-oriented FormType

FormType::buildForm() object oriented instead of array, (*5)

Example:, (*6)

namespace FooBundle\Form\Type;

use Steevanb\SymfonyFormOptionsBuilder\OptionsBuilder\EmailOptionsBuilder;
use Steevanb\SymfonyFormOptionsBuilder\OptionsBuilder\TextOptionsBuilder;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class BarType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        # Since PHP 5.5, you can use FooClass::class
        $builder->add('field_text', TextType::class, TextOptionsBuilder::create()->asArray());

        # Since PHP 5.6, you can use the variadic syntax. asVariadic() parameter is field name.
        $builder->add(
            ...EmailOptionsBuilder::create()
                ->setRequired(false)
                ->setPlaceHolder('default@mail.com')
                ->setTrim(false)
                ->asVariadic('field_email')
        );
    }
}

More documentation, (*7)

BlockPrefixTrait

Add getBlockPrefix(), to always return same syntax for form type getBlockPrefix() method: form_type_formtypeclassname, (*8)

Example:, (*9)

namespace FooBundle\Form\Type;

use Steevanb\SymfonyFormOptionsBuilder\BlockPrefixTrait;

class BarType extends AbstractType
{
    # Use this trait to define getBlockPrefix() required method. It will return form_type_bar
    use BlockPrefixTrait;
}

The Versions

31/05 2016

dev-master

9999999-dev

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

30/05 2016

dev-symfony-2

dev-symfony-2

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

30/05 2016

2.1.4

2.1.4.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

31/12 2015

2.1.3

2.1.3.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

09/12 2015

2.1.2

2.1.2.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

08/12 2015

2.1.1

2.1.1.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

03/12 2015

2.1.0

2.1.0.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

02/12 2015

2.0.2

2.0.2.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

02/12 2015

2.0.1

2.0.1.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

01/12 2015

2.0.0

2.0.0.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

28/10 2015

1.4.2

1.4.2.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

09/10 2015

1.4.1

1.4.1.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

01/10 2015

1.4.0

1.4.0.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

01/10 2015

1.3.4

1.3.4.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

30/09 2015

1.3.3

1.3.3.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

28/09 2015

1.3.2

1.3.2.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

18/09 2015

1.3.1

1.3.1.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

18/09 2015

1.3.0

1.3.0.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

16/09 2015

1.2.0

1.2.0.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

21/08 2015

1.1.2

1.1.2.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

11/08 2015

1.1.1

1.1.1.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

03/08 2015

1.1.0

1.1.0.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires

 

13/07 2015

1.0.0

1.0.0.0

buildForm() with objects instead of array

  Sources   Download

MIT

The Requires