Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
入力フィールド (名前、場所、位置) のルールがないため、モデルのルール関数は空の配列を返しますが、空の値がデータベース テーブルに保存されます。
public function rules() { return array(); }
また、モデルから rules() 関数を省略した場合
$モデル->保存()
true を返しますが、DB テーブルには空の値が挿入されます。
では、モデル クラスから rules() 関数を省略するにはどうすればよいでしょうか。
したがって、それらすべてをsafeルールの属性として設定する必要があります。
safe
public function rules(){ return array array('id, name, /*list attribute here*/', 'safe') ); }
重要なポイント - Massive Assignment は、明示的な検証ルールに合格したフィールドに対してのみ行われます。