Sadikhasan
Sadikhasan

Reputation: 18600

Delete div generated by CakePHP Form create

CakePHP Code

<?php echo $this->Form->create('KPI');?>

HTML Output

<form accept-charset="utf-8" method="post" id="..." action="...">
   <div style="display:none;">
       <input type="hidden" value="POST" name="_method">
   </div>

I want to delete auto generated div which display in html output. How can delete that div which generated by cakephp form create?

Upvotes: 1

Views: 643

Answers (2)

ndm
ndm

Reputation: 60453

As already mentioned in the comments, you should not remove that markup, besides that would only be possible by completely overwriting FormHelper::create(), see

Also note that there might be an additional hidden block at the end of the form, see FormHelper::secure().

The only simpler way to remove the wrapper, would be to remove the hidden wrappers altogether, that would for example be possible by using a custom config for HtmlHelper where the hiddenblock tag is modified so that it doesn't contain the wrapper, however that's not a good idea - don't do it!

The problem here is that you can't just remove this specific wrapping div element, the hidden input and the div go hand in hand. And the input ensures that CakePHP is able to figure the proper request method (POST, PUT, DELETE).

So instead simply make your jQuery selector more specific, do not just select div elements, instead make sure that your elements have a proper class set, and then select them by that class.

Upvotes: 1

Sharma Vikram
Sharma Vikram

Reputation: 2470

    <?php echo $this->Form->create('Kpi', array(
              'inputDefaults'=>array('div'=>'false', 'label'=>false)));
         ?>

Upvotes: 0

Related Questions