Search code examples
phpcakephpform-helpers

div false not working with input submit cakephp


I am using Form Helper to create an input submit button but I am confused as to why 'div'=>false is not working for me.

Here is my php code:

echo $this->Form->input('Save', 
            array('type'=>"submit",
                  'class'=>'btn btn-primary',
                  'div'=>false, 
                  'label'=>false));

Which gives me output:

<div class="submit"><!--unwanted div-->
  <input class="btn btn-primary" type="submit" value="Save">
</div>

But when I tried with input 'type'=>'button' it works like:

echo $this->Form->input('Save', 
            array('type'=>"button",
                  'class'=>'btn btn-primary',
                  'div'=>false, 
                  'label'=>false));

And gives me perfect output:

<input class="btn btn-primary" type="submit" value="Save">

But I don't want this extra div with type submit.


Solution

  • Try this

    echo $this->Form->submit('Save',
                       array('div'=>false,
                       "class"=>"btn btn-primary"
                       ));