This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

kubuss8822438
kubuss8822438

Hi,

I've setup some fields to be required (have red dot next to them) in fields.yaml. But if backend administrator not fill those form still proceed and i get SQL error - becouse i've set them required (not nullable). Any idea what that might happend? I've tested it in two different instalations of October.

Pavel Chernov
Pavel Chernov

From docs: https://octobercms.com/docs/backend/forms#form-field-options

required - places a red asterisk next to the field label to indicate it is required (make sure to setup validation on the model as this is not enforced by the form controller).

So, you should add to your model trait and rules (https://octobercms.com/docs/database/traits#validation)

kubuss8822438
kubuss8822438

Ohh.. Okay, get it now. required mark only put red dot. Thank you a lot! :)

Digital Artisans
Digital Artisans

for those still tumbling upon this post:

Lets say you want the field title to be required, edit this file in your model's php file

    public $rules = [
        'title' => 'required'
    ];

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.