Hamza
Hamza

Reputation: 37

How can I get value from twig form?

Supposing I have a twig like this, how can I get input value from my controller?

{{form_start(form)}}
{{form_row(form.row1}}
{{form_row(form.row2}}
{{form_row(form.row3}}
   <input id='someid'>
{{form_end(form}}

Upvotes: 2

Views: 2764

Answers (2)

Matteo
Matteo

Reputation: 39380

You can access as:

$request->request->get('someid', 'default values');

More info here.

Upvotes: 1

Alvin Bunk
Alvin Bunk

Reputation: 7764

I used the link from @Matteo 's answer, which is also correct. For your case I think it would be like this:

$someid = $request->query->get('someid');

Try that.

Upvotes: 0

Related Questions