Symfony 2 This form should not contain extra fields -


i created form using formbuilder in symfony. add basic styling form inputs using external stylesheet , referencing tag id. form renders correctly , processes information correctly.

however, outputs unwanted unordered list list item containing following text: this form should not contain fields.

i having hard time getting rid of notice. wondering if can me understand why being rendered form , how remove it?

many in advance!

controller

$form = $this->createformbuilder($search)         ->add('searchinput', 'text', array('label'=>false, 'required' =>false))         ->add('search', 'submit')         ->getform();  $form->handlerequest($request); 

twig output (form outputted , processed correctly

this form should not contain fields. 

rendered html

<form method="post" action="">     <div id="form">        <ul>            <li>this form should not contain fields.</li>        </ul>        <div>           <input type="text" id="form_searchinput" name="form[searchinput]" />        </div>        <div>           <button type="submit" id="form_search" name="form[search]">search</button>        </div>        <input type="hidden" id="form__token" name="form[_token]" value="bb342d7ef928e984713d8cf3eda9a63440f973f2" />     </div>  </form> 

it seems me have problem because of token field. if so, try add options createformbuilder():

$this->createformbuilder($search, array(         'csrf_protection' => true,         'csrf_field_name' => '_token',     ))     ->add('searchinput', 'text', array('label'=>false, 'required' =>false))     ->add('search', 'submit')     ->getform(); 

to find out field use code in controller, request:

$data = $request->request->all();  print("request data<br/>"); foreach ($data $k => $d) {     print("$k: <pre>"); print_r($d); print("</pre>"); }  $children = $form->all();  print("<br/>form children<br/>"); foreach ($children $ch) {     print($ch->getname() . "<br/>"); }  $data = array_diff_key($data, $children); //$data contains fields  print("<br/>diff data<br/>"); foreach ($data $k => $d) {     print("$k: <pre>"); print_r($d); print("</pre>"); }  $form->bind($data); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -