Symfony2 form to JSON structure

How can the Symfony2 form be transformed to JSON data structure? Looking for proper bundle gave me no results;

Example:

$builder
    ->add('name', 'text')
    ->add('password', 'password')
;

Would result in something like that:

{
    fields: {
        name: {
            type: 'text'
        },
        password: {
            type: 'password'
        }
    }
}

Iterating over each element in form after $form = $this->createForm(new FormType(), new Entity()) was not helpful, could not find some properties that could be defined in form builder.


Source: forms

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.