I use Drupal 7.x. I add several fields in the user profile form.
In the registration i don't need them, but in the first login it must be filled. I can't use Profile2 module.
In my module:
function mymodule_form_user_profile_form_alter(&$form, &$form_state) {
$form['field_test_field']['#required'] = 'TRUE';
}
The function is fired, but don't make it required.
I tried also:
$form['field_test_field'][0]['#required'] = 'TRUE';
$form['#field_info']['field_test_field']['required'] = '1';
How can make an user_profile_form
field Required in the form alter?