[users-module] Required option on field not working on formbuilder

lckamal - 10 months ago

I have set required option for first_name and last_name in MyRegisterFormBuilder.php but validation is not working.

protected $fields = [
        'first_name' => [
            'instructions' => false,
            'placeholder' => 'theme::field.first_name.name',
            'required' => true,
            'validators'   => [
                'first_name.required' => [
                    'message' => 'First Name is required.',
                ],
            ],
        ]
...
]

ryanthompson - 10 months ago

Hmm.. trying to overload core messages for validation?

Have you tried just required and drop the first_name. prefix?

lckamal - 10 months ago

I am trying because I have to signup for different roles with radio button. Not working with the suggestions. Tried like this also:

'first_name' => [
            'instructions' => false,
            'placeholder' => 'theme::field.first_name.name',
            'rules' => [
                'required' => true
            ],
            'required' => true,
            'validators'   => [
                'required' => [
                    'message' => 'First Name is required.',
                ],
            ],
        ],

ryanthompson - 10 months ago

Rules would just be required - not required -> true (and you can leave off the top level required->true too).

Did you checkout that class and see where the issue might be?

lckamal - 10 months ago

This is the code I have used. not sure how the problem arised. http://jmp.sh/kbbzQGv

ryanthompson - 10 months ago

So you would want to bind to THAT form builder. Not the one I was saying. I must have gotten confused?