{"id":2523,"date":"2024-11-10T10:16:37","date_gmt":"2024-11-10T02:16:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2523\/"},"modified":"2024-11-10T10:16:37","modified_gmt":"2024-11-10T02:16:37","slug":"yii%e4%b8%adconfirm%e5%a4%b1%e6%95%88%ef%bc%8c%e7%9b%b4%e6%8e%a5%e6%89%a7%e8%a1%8c%e5%90%8e%e7%bb%ad%e4%bb%a3%e7%a0%81%e7%9a%84%e5%8e%9f%e5%9b%a0%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2523\/","title":{"rendered":"Yii\u4e2dconfirm\u5931\u6548\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u4ee3\u7801\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173078316440403.jpg\" class=\"aligncenter\" title=\"Yii\u4e2dconfirm\u5931\u6548\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u4ee3\u7801\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" alt=\"Yii\u4e2dconfirm\u5931\u6548\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u4ee3\u7801\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>yii\u7684confirm\u4e3a\u4f55\u5931\u6548\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u4ee3\u7801\uff1f<\/strong><\/p>\n<p>\u5728yii\u4e2d\u4f7f\u7528confirm\u63d0\u793a\u7528\u6237\u786e\u8ba4\u64cd\u4f5c\uff0c\u4f46\u6709\u65f6\u4f1a\u51fa\u73b0\u786e\u8ba4\u6846\u672a\u5f39\u51fa\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u64cd\u4f5c\u7684\u60c5\u51b5\u3002\u8fd9\u53ef\u80fd\u662f\u7531\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\u7684\uff1a<\/p>\n<p><strong>\u6ca1\u6709\u52a0\u8f7d\u5fc5\u8981\u7684js\u6587\u4ef6<\/strong><\/p>\n<p>\u786e\u4fdd\u5728\u89c6\u56fe\u4e2d\u52a0\u8f7d\u4e86yii\u7684activefield\u548cactiveform\u7ec4\u4ef6\u6240\u5fc5\u9700\u7684js\u6587\u4ef6\u3002<\/p>\n<p><strong>\u4ece\u9519\u8bef\u4f4d\u7f6e\u8c03\u7528confirm<\/strong><\/p>\n<p>confirm\u65b9\u6cd5\u5e94\u5728\u6309\u94ae\u6216\u94fe\u63a5\u7684click\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\u8c03\u7528\uff0c\u800c\u4e0d\u662f\u5728\u63a7\u5236\u5668\u6216\u89c6\u56fe\u4e2d\u3002<\/p>\n<p><strong>\u683c\u5f0f\u9519\u8bef\u7684confirm\u6d88\u606f<\/strong><\/p>\n<p>confirm\u6d88\u606f\u5fc5\u987b\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5e76\u4e14\u5fc5\u987b\u7528\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7\u5f15\u8d77\u6765\u3002<\/p>\n<p><strong>\u4fee\u6b63\u4ee3\u7801<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4fee\u6539\u540e\u7684\u89c6\u56fe\u4ee3\u7801\uff0c\u4ee5\u786e\u4fddconfirm\u6b63\u5e38\u5de5\u4f5c\uff1a<\/p>\n<pre>&lt;?php\nuse yiihelpershtml;\nuse yiiwidgetsdetailview;\n\n\/* @var $this yiiwebiew *\/\n\/* @var $model appmodelssetting *\/\n\n$this-&gt;title = $model-&gt;name;\n\n?&gt;\n&lt;div class=\"setting-view\"&gt;\n\n    &lt;h1&gt;&lt;?php echo html::encode($this-&gt;title) ?&gt;&lt;\/h1&gt;\n\n    &lt;p&gt;\n        &lt;?php echo html::a(yii::t('app', 'update'), ['update', 'id' =&gt; $model-&gt;id], ['class' =&gt; 'btn btn-primary']) ?&gt;\n        &lt;?php echo html::a(yii::t('app', 'delete'), ['delete', 'id' =&gt; $model-&gt;id], [\n            'class' =&gt; 'btn btn-danger',\n            'data' =&gt; [\n                'confirm' =&gt; 'are you sure you want to delete this item?',\n                'method' =&gt; 'post',\n            ],\n        ]) ?&gt;\n    &lt;\/p&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528data-confirm\u5c5e\u6027\u66ff\u4ee3confirm\u9009\u9879\uff1a<\/strong><\/p>\n<pre>&lt;?php echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' =&gt; $model-&gt;id], ['data-confirm' =&gt; 'Are you sure you want to delete this item?']) ?&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fYii\u4e2dconfirm\u5931\u6548\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u4ee3\u7801\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>yii\u7684confirm\u4e3a\u4f55\u5931\u6548\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u4ee3\u7801\uff1f \u5728yii\u4e2d\u4f7f\u7528confirm\u63d0\u793a\u7528\u6237\u786e\u8ba4\u64cd\u4f5c\uff0c\u4f46\u6709\u65f6\u4f1a\u51fa\u73b0\u786e\u8ba4\u6846\u672a\u5f39\u51fa\uff0c\u76f4\u63a5\u6267\u884c\u540e\u7eed\u64cd\u4f5c\u7684\u60c5\u51b5\u3002\u8fd9\u53ef\u80fd\u662f\u7531\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\u7684\uff1a \u6ca1\u6709\u52a0\u8f7d\u5fc5\u8981\u7684js\u6587\u4ef6 \u786e\u4fdd\u5728\u89c6\u56fe\u4e2d\u52a0\u8f7d\u4e86yii\u7684activefield\u548cactiveform\u7ec4\u4ef6\u6240\u5fc5\u9700\u7684js\u6587\u4ef6\u3002 \u4ece\u9519\u8bef\u4f4d\u7f6e\u8c03\u7528confirm confirm\u65b9\u6cd5\u5e94\u5728\u6309\u94ae\u6216\u94fe\u63a5\u7684click\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u4e2d\u8c03\u7528\uff0c\u800c\u4e0d\u662f\u5728\u63a7\u5236\u5668\u6216\u89c6\u56fe\u4e2d\u3002 \u683c\u5f0f\u9519\u8bef\u7684confirm\u6d88\u606f confirm\u6d88\u606f\u5fc5\u987b\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5e76\u4e14\u5fc5\u987b\u7528\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7\u5f15\u8d77\u6765\u3002 \u4fee\u6b63\u4ee3\u7801 \u4ee5\u4e0b\u662f\u4fee\u6539\u540e\u7684\u89c6\u56fe\u4ee3\u7801\uff0c\u4ee5\u786e\u4fddconfirm\u6b63\u5e38\u5de5\u4f5c\uff1a &lt;?php use yiihelpershtml; use yiiwidgetsdetailview; \/* @var $this yiiwebiew *\/ \/* @var $model appmodelssetting *\/ $this-&gt;title = $model-&gt;name; ?&gt; &lt;div class=&#8221;setting-view&#8221;&gt; &lt;h1&gt;&lt;?php echo html::encode($this-&gt;title) ?&gt;&lt;\/h1&gt; &lt;p&gt; &lt;?php echo html::a(yii::t(&#8216;app&#8217;, &#8216;update&#8217;), [&#8216;update&#8217;, &#8216;id&#8217; =&gt; $model-&gt;id], [&#8216;class&#8217; =&gt; &#8216;btn btn-primary&#8217;]) ?&gt; &lt;?php echo html::a(yii::t(&#8216;app&#8217;, &#8216;delete&#8217;), [&#8216;delete&#8217;, &#8216;id&#8217; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2523","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2523"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2523\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}