久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在表單內使用 FormHelper::postLink()?

How to use FormHelper::postLink() inside of a form?(如何在表單內使用 FormHelper::postLink()?)
本文介紹了如何在表單內使用 FormHelper::postLink()?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想在表單中創建一個 Cakephp 刪除帖子鏈接,如下所示.但是當我在瀏覽器中檢查時,第一個刪除帖子按鈕不包括刪除表單并且無法刪除,但其他按鈕包括我想要的并且可以刪除.

I want to create a Cakephp delete post link within form like the following. But the very first delete post button doesn't include delete Form when I inspect in browser and can't delete but the others include as I want and can delete.

是 cakephp 錯誤還是我需要更改源代碼?

Is it cakephp bug or something I need to change my source code?

<?php
echo $this->Form->create('Attendance', array('required' => false, 'novalidate' => true));

foreach($i = 0; $i < 10; i++):
    echo $this->Form->input('someinput1', value => 'fromdb');
    echo $this->Form->input('someinput2', value => 'fromdb');
    echo $this->Form->postLink('Delete',array('action'=>'delete',$attendanceid),array('class' => 'btn btn-dark btn-sm col-md-4','confirm' => __('Are you sure you want to delete')));
endforeach;

echo $this->Form->button('Submit', array('class' => 'btn btn-success pull-right'));
echo $this->Form->end();
?>

推薦答案

表單不能嵌套,HTML 標準根據定義禁止嵌套.如果您嘗試這樣做,大多數瀏覽器將刪除嵌套表單并將其內容呈現在父表單之外.

Forms cannot be nested, the HTML standard forbids that by definition. If you try to, most browsers will drop the nested form and render its contents outside of the parent form.

如果您需要在現有表單中發布鏈接,那么您必須使用 inlineblock 選項(從 CakePHP 2.5 開始可用,inline> 已在 CakePHP 3.x 中刪除),以便將新表單設置為可以在主表單之外呈現的視圖塊.

If you need post links inside of existing forms, then you must use the inline or block options (available as of CakePHP 2.5, inline has been removed in CakePHP 3.x), so that the new form is being set to a view block that can be rendered outside of the main form.

CakePHP 2.x

echo $this->Form->postLink(
    'Delete',
    array(
        'action' => 'delete',
        $attendanceid
    ),
    array(
        'inline' => false, // there you go, disable inline rendering
        'class' => 'btn btn-dark btn-sm col-md-4',
        'confirm' => __('Are you sure you want to delete')
    )
);

CakePHP 3.x

echo $this->Form->postLink(
    'Delete',
    [
        'action' => 'delete',
        $attendanceid
    ],
    [
        'block' => true, // disable inline form creation
        'class' => 'btn btn-dark btn-sm col-md-4',
        'confirm' => __('Are you sure you want to delete')
    ]
);

關閉主表單并輸出帖子鏈接表單

// ...

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

// ...

echo $this->fetch('postLink'); // output the post link form(s) outside of the main form

另見

CakePHP 2.x

  • API > FormHelper::postLink()
  • 食譜 > 視圖 > 使用視圖塊

CakePHP 3.x

  • API > CakeViewHelperFormHelper::postLink()
  • Cookbook > Views > Helpers > Form > 創建獨立按鈕和 POST 鏈接
  • 食譜 > 視圖 > 使用視圖塊

這篇關于如何在表單內使用 FormHelper::postLink()?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cannot use #39;Object as class name as it is reserved Cake 2.2.x(不能使用 Object 作為類名,因為它是保留的 Cake 2.2.x)
Session is lost after an OAuth redirect(OAuth 重定向后會話丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁排序)
CakePHP Shared core for multiple apps(CakePHP 多個應用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯誤:允許的內存大小為 134217728 字節已用盡(嘗試分配 87 字節))
主站蜘蛛池模板: 国产欧美一区二区在线观看 | 日韩免费一区二区 | 欧美激情精品久久久久久 | 国产1区 | 欧美综合久久久 | 欧美一区视频 | 中国一级特黄毛片大片 | 精品国产一级 | 成人日韩av | 日本中文字幕日韩精品免费 | 日韩精品视频在线观看一区二区三区 | 日本大香伊一区二区三区 | 欧美a级成人淫片免费看 | 免费亚洲网站 | 欧美视频在线一区 | 成人国产精品色哟哟 | 日韩一区二区免费视频 | 亚洲视频一区二区三区 | 日韩欧美综合在线视频 | 青青艹在线视频 | 久久99精品久久久久久狂牛 | 人人插人人 | 韩国精品在线 | 在线欧美小视频 | 久久久成人网 | 亚洲成人一二区 | 国产一区二区三区免费观看在线 | 97av视频在线| 日韩精品一区二区三区视频播放 | 日韩中文视频 | 青青草一区 | 久久精品日产第一区二区三区 | 午夜爱爱毛片xxxx视频免费看 | av激情在线 | 久久国产欧美日韩精品 | 爱高潮www亚洲精品 中文字幕免费视频 | 久久久久久久久久性 | 91电影| 天天天操操操 | 天天插天天狠天天透 | 久久久久久看片 |