Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

forms - Access an unmapped field in Symfony2 Controller

I am creating forms with an unmapped field as explained in the form documentation.

However when in the controller or similar I want to access it, currently I am using the POST request array and getting out from there like so:

$postData = $this->getRequest()->request->get('my_form_name');
$unmappedField = $postData['unmapped_field']

I just can't help but thinking this is not the best way, and I cannot find anything on the official documentation.

Is there a better way than this?

question from:https://stackoverflow.com/questions/17083796/access-an-unmapped-field-in-symfony2-controller

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can access unmapped field in form

$unmappedField = $form['unmapped_field']->getData();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...