Hello, thank you for the module. I encountered problem similar to the one from New feature "This field is required for:" but with Drupal 7 version.
I fixed it by changing this code:
/**
* Implements hook_field_widget_form_alter().
*/
function multiple_registration_field_widget_form_alter(&$element, &$form_state, $context) {
$instance = isset($context['instance']) ? $context['instance'] : array();
if (!empty($instance['settings']['user_additional_register_form'])) {
// If nothing was selected.
if (max($instance['settings']['user_additional_register_form']) === 0) {
return;
}
$element['#access'] = multiple_registration_is_field_accessible($instance);
}
}to this:
/**
* Implements hook_field_widget_form_alter().
*/
function multiple_registration_field_widget_form_alter(&$element, &$form_state, $context) {
$instance = isset($context['instance']) ? $context['instance'] : array();
if (!empty($instance['settings']['user_additional_register_form'])) {
// If nothing was selected.
if (max($instance['settings']['user_additional_register_form']) === 0) {
return;
}
$element['#access'] = multiple_registration_is_field_accessible($instance);
if(!$element['#access']){
$element['value']['#required'] = FALSE;
}
}
}If user should access the field from registration page value of #required is unchanged, but if the #access is FALSE and field is not available to the user, then #required is set to FALSE, so that user can submit registration form successfully.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | multiple_registration-required-field-30348277-0004.patch | 473 bytes | karschsp |
Comments
Comment #2
ysamoylenko commentedComment #3
ysamoylenko commentedComment #4
karschsp commentedHere's a patch that incorporates @miksha's snippet from the original issue summary.
Comment #6
ysamoylenko commentedThank you for the report.
The patch was committed.