symfony 2创建自定义表单如何获取表单自定义元素?

$form = $this->createForm(new OrganizationType(), $entity, array(
        'action' => $this->generateUrl('_control_organization_create'),
        'method' => 'POST',
    ));

    $form->add('submit', 'submit', array('label' => 'Create'));

    return $form;

there is action and method defined. how to get this? in template engine twig into custom render?

By calling,

{{ form(form) }}

Or,

{{ form_start(form) }}

the action and method options values you added to your form definition are used.

From the documentation ...

Also, check Building The Form section of the documentation to see how to render the HTML form by passing

array('form' => $form->createView()) 

to the render helper within your controller.

Then, take a look at Rendering the Form part of the same documentation.

Also ...

If you want to override them in your template, you've to pass the right values to your form() or form_start() helpers as follow,

{{ form(form, {'action': path('target_route'), 'method': 'GET'}) }}

{{ form_start(form, {'action': path('target_route'), 'method': 'GET'}) }}
Return your form like this

return $this->render('Your Bundle name: Your controller name : Your twig file', array(
            'form' => $form->createView(),
        ));


And in your twig file get the form like this:

{{ form(form) }}