[users-module] Required option on field not working on formbuilder
Created 7 years ago by lckamalI 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.', ], ], ] ... ]
lckamal
—
7 years 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
—
7 years 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
—
7 years ago
This is the code I have used. not sure how the problem arised. http://jmp.sh/kbbzQGv
ryanthompson
—
7 years ago
So you would want to bind to THAT form builder. Not the one I was saying. I must have gotten confused?
Hmm.. trying to overload core messages for validation?
Have you tried just
required
and drop thefirst_name.
prefix?