第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

cakephp 驗(yàn)證不適用于 save()

cakephp 驗(yàn)證不適用于 save()

PHP
白豬掌柜的 2023-03-26 16:03:23
我只是在 cakephp(2.x) 中應(yīng)用驗(yàn)證規(guī)則。當(dāng)我保存數(shù)據(jù)時(shí),它會(huì)在不驗(yàn)證表單的情況下保存到數(shù)據(jù)庫中。我無法找到我缺少的地方。我是 cakephp 的初學(xué)者。請(qǐng)建議我如何驗(yàn)證我的表格。我的表單結(jié)構(gòu)如下所示。<form class="form-horizontal" method="POST" action="saveUser">    <fieldset>        <legend>Register</legend>        <span class = "error">* Required field</span>        <div class="form-group">        <label for="inputName" class="col-lg-2 control-label">Name &nbsp;<span class="error">*</span></label>        <div class="col-lg-10">            <input type="text" class="form-control" id="inputName" name="name" placeholder="Name" required value="">        </div>        </div>        <div class="form-group">        <label for="inputEmail" class="col-lg-2 control-label">Email&nbsp;<span class="error">*</span></label>        <div class="col-lg-10">            <input type="email" class="form-control" id="inputEmail" name="email" placeholder="Email" required value="">        </div>        </div>        <div class="form-group">        <label for="inputPassword" class="col-lg-2 control-label">Password&nbsp;<span class="error">*</span></label>        <div class="col-lg-10">            <input type="password" class="form-control" id="inputPassword" name="password" placeholder="Password" required value="">        </div>        </div>        <div class="form-group">        <div class="col-lg-10 col-lg-offset-2">            <button type="reset" class="btn btn-default">Cancel</button>            <button type="submit" class="btn btn-primary">Submit</button>        </div>        </div>    </fieldset></form>和模型這樣驗(yàn)證數(shù)組public $validate = array(    'name' => array(        'alphaNumeric' => array(            'rule' => 'alphaNumeric',            'required' => true,            'message' => 'Only Allows Letter and Numbers'        ),        'between' => array(            'rule' => array('lengthBetween', 5, 15),            'message' => 'length upto 5 to 15 character'        )    ),
查看完整描述

1 回答

?
臨摹微笑

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊

如果您分配自己的名稱,CakePHP 無法將輸入字段與模型列匹配。例如:


<input type="text" class="form-control" id="inputName" name="name" placeholder="Name" required value="">

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^^

... 應(yīng)該


name="data[User][name]"?

如果您將 CakePHP 用于模型和控制器,那么將它也用于視圖會(huì)更容易:


<?php

echo $this->Form->create('User');

echo $this->Form->input('name');


查看完整回答
反對(duì) 回復(fù) 2023-03-26
  • 1 回答
  • 0 關(guān)注
  • 114 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)