File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
user_guide_src/source/models Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,17 @@ potential mass assignment vulnerabilities.
157
157
158
158
.. note :: The `$primaryKey`_ field should never be an allowed field.
159
159
160
+ $allowEmptyInserts
161
+ ------------------
162
+
163
+ .. versionadded :: 4.3.0
164
+
165
+ Whether to allow inserting empty data. The default value is ``false ``, meaning
166
+ that if you try to insert empty data, an exception with
167
+ "There is no data to insert." will raise.
168
+
169
+ You may also change this setting with the :ref: `model-allow-empty-inserts ` method.
170
+
160
171
Dates
161
172
-----
162
173
@@ -371,6 +382,8 @@ You can use ``allowEmptyInserts()`` method to insert empty data. The Model throw
371
382
372
383
.. literalinclude :: model/056.php
373
384
385
+ You may also change this setting with the `$allowEmptyInserts `_ property.
386
+
374
387
You can enable the check again by calling ``allowEmptyInserts(false) ``.
375
388
376
389
update()
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class UserModel extends Model
16
16
17
17
protected $ allowedFields = ['name ' , 'email ' ];
18
18
19
+ protected bool $ allowEmptyInserts = false ;
20
+
19
21
// Dates
20
22
protected $ useTimestamps = false ;
21
23
protected $ dateFormat = 'datetime ' ;
You can’t perform that action at this time.
0 commit comments