1

After a lot of searching, I've been unable to find the answer by myself, so here's my problem (with Drupal 7) :

I've been able to add new fields to my user registration form (config/people/accounts/fields) and even hide fields on the form... But I would like to do the opposite : display a field on the registration form whose only purpose would be to assign a value to another field upon validation. There would be no need for this field to be stored in the database (like a transient property in Java).

Is there a way to achieve that ? Thx

1 Answer 1

3

Yep! Take a look at:

yourtheme_form_user_register_form_alter

Add a new value to the form there, and then change the form's saving function. In your new saving function you can do whatever you need to do with custom validation and re-assigning that value.

https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_form_alter/7

1
  • Thanks a lot, and I've discovered the use of the weight property to add the new field at the end of the form (it was by default created at the top)... Commented Feb 20, 2015 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.