salmiak Posted October 16, 2018 Share Posted October 16, 2018 I'm trying to add a (required) unique text field to my registration form using the LoginRegister module. (Like e-mail and user name) I tried using FieldtypeTextUnique but of course its's not that simple. That just adds the user with an empty field if it exists already. I figure I have to hook a function somewhere or something but don't know how to go about that. Link to comment Share on other sites More sharing options...
elabx Posted October 16, 2018 Share Posted October 16, 2018 As for making the field required, from what I can tell from the source code you need to set the field in the user template as required so it is also required in the registration form. (but I also see that it checks if the field is InputfieldText) I guess you could also make an after hook in the buildForm method, and traverse the form to set the field you want as required, try placing this in site/ready.php and let me know if it worked: $this->addHookAfter('LoginRegister::buildRegisterForm', function($event) { $form = $event->return; $field = $form->get('the_unique_text_field_name'); $field->attr('required','required'); $event->return = $form; }); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now