1
max_lengthの検証を動的に設定できますか?たとえばmax_length['.$this->store->select($id)->stock.']
<のために - それはちょうど$this->store->select($id)->stock
が有効な数値を返す、確認してCodeigniterの動的最大長の値
max_lengthの検証を動的に設定できますか?たとえばmax_length['.$this->store->select($id)->stock.']
<のために - それはちょうど$this->store->select($id)->stock
が有効な数値を返す、確認してCodeigniterの動的最大長の値
を働いていない:
$this->form_validation
->set_rules(
'your_field',
'Label',
'max_length['.$this->store->select($id)->stock.']'
// You can also trim it before checking length like below
//'trim|max_length['.$this->store->select($id)->stock.']'
);
は、これは私のモデルである:関数は($ ID){返します$ this-> DB-> get_whereを選択します( 'store'、array( 'id' => $ id)) - > row(); } – user3206703
@ user3206703 'id'レコードが存在しない可能性があります。そのような場合に' row() 'を使って' - > stock'によってアクセスすると、うまくいかないかもしれません。 row = $ this-> store-> select($ id); if(isset($ row)){$ stock = $ row->株;あなたが制限したい場合は、在庫がないので、 'less_than [10]'のように使うことができます。 'max_length'はcharの長さです。 –
@ user3206703:ありがとう、ありがとう問題を解決した後に受け入れるために解決しました。 –