Incorrect method in form generated by CakePHP 2.4

4

My problem occurs with the following code:

<?php
echo $this->Form->create(
  'Page',
  array(
    'url' => array(
      'controller' => 'pages',
      'action' => 'delete',
      $this->request->data['Page']['id'],
      'admin' => true
    ),
    'id' => 'PageDeleteForm',
    'method' => 'POST',
    'class' => 'hide'
  )
);

echo $this->Form->end();
?>

The result of this is as follows:

<form action="/admin/pages/delete/16" id="PageDeleteForm" method="post" class="hide" accept-charset="utf-8">
  <div style="display:none;">
    <input type="hidden" name="_method" value="PUT">
  </div>
</form>

CakePHP returns me: Method not allowed , since my action only allows POST or DELETE .

Why is the _method field being generated with the value PUT ?

    
asked by anonymous 16.01.2014 / 17:19

1 answer

4

I'm not sure, but I think CakePHP got confused when you passed 'method'=> 'POST' as an option.

The default parameter, per documentation , is type , not method (which is the name of the generated attribute).

  

type Form method defaults to POST

    
16.01.2014 / 17:58