function _fc_form_profile2_form_alter in Field Complete 7
Implements hook_form_profile2_form_alter().
Profile2 behaves very non-standardly with its edit-form handling so we have to try to see if we can't get round its nonsense.
1 call to _fc_form_profile2_form_alter()
- fc_form_profile2_form_alter in ./
fc.module - Implements hook_form_profile2_form_alter().
File
- ./
fc.form.inc, line 208 - Field Complete - Provides field-based completeness for any entity - admin.
Code
function _fc_form_profile2_form_alter(&$form, &$form_state) {
// Must check that there are fields first: https://drupal.org/node/2049945
// and further developments on that issue. It's feasible that this may be
// called during registration, in which case we want to do nothing.
if (empty($form_state['field']) || empty($form_state['entity_type']) || $form_state['entity_type'] != 'profile2') {
// No fields so let's just get out of here.
return;
}
$entity_type = $form_state['entity_type'];
$entity = $form_state[$form_state['entity_type']];
$langcode = entity_language($entity_type, $entity);
if (empty($langcode)) {
$langcode = LANGUAGE_NONE;
}
foreach ($form_state['field']['#parents'] as $profile_name => $profile_fields) {
foreach ($profile_fields['#fields'] as $field_name => $field_data) {
if (empty($field_data[$langcode])) {
// No field data for the current language
continue;
}
$instance = $field_data[$langcode]['instance'];
if (!empty($instance['settings']['fc']['fc_include']) && !$instance['deleted'] && !empty($form[$profile_name][$field_name])) {
// Add my after build function
$form[$profile_name][$field_name][$langcode]['#after_build'][] = 'fc_field_attach_after_build';
}
}
}
$form['#pre_render'][] = 'fc_form_pre_render';
}