CakePHP4でpostLinkしたら、エラーでた。Cannot read properties of undefined (reading ‘submit’)

file
CakePHP4でpostLinkしたらエラーが出てきました。

Cannot read properties of undefined (reading 'submit')

原因はFormの中でpostLinkをすると出てしまうみたい。

対処方法

  1. block => trueをつける
  2. formの外に、$this->fetch('postLink')を追加する

この二つをやると直りました。

<?= $this->Form->create($hoge, ['type' => 'file']) ?>
<?= $this->Form->postLink(__('削除'),
  ['action' => 'delete', $project->id],
  ['block' => true, 'confirm' => __('削除しますか?')]
  )
?>
<?= $this->Form->button(__('保存')) ?>
<?= $this->Form->end() ?>
<?= $this->fetch('postLink') ?>

外に出してform送信にならないようにcakeがしてくれてるんですね、便利便利

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です