function _geocoder_field_alter_form_fields in Geocoder 8.3
Same name and namespace in other branches
- 8.2 modules/geocoder_field/geocoder_field.module \_geocoder_field_alter_form_fields()
Helper function for disable or hide geocode fields.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: Entity.
array $form: Form.
2 calls to _geocoder_field_alter_form_fields()
- geocoder_field_form_alter in modules/
geocoder_field/ geocoder_field.module - Implements hook_form_alter().
- geocoder_field_inline_entity_form_entity_form_alter in modules/
geocoder_field/ geocoder_field.module - Implements hook_inline_entity_form_entity_form_alter().
File
- modules/
geocoder_field/ geocoder_field.module, line 55 - Geocoder Field module.
Code
function _geocoder_field_alter_form_fields(ContentEntityInterface $entity, array &$form) {
foreach ($entity
->getFields() as $field_name => $field) {
/** @var \Drupal\Core\Field\FieldConfigInterface $field_config */
if (!($field_config = $field
->getFieldDefinition()) instanceof FieldConfigInterface) {
// Only configurable fields are subject of geocoding.
continue;
}
// Eventually Disable the Geocoded Field.
$geocoder = $field_config
->getThirdPartySettings('geocoder_field');
if (isset($geocoder['method']) && $geocoder['method'] !== 'none') {
if (isset($geocoder['disabled']) && $geocoder['disabled'] == TRUE) {
$form[$field_name]['#disabled'] = TRUE;
}
// Eventually Hide the Geocoded Field.
if (isset($geocoder['hidden']) && $geocoder['hidden'] == TRUE) {
$form[$field_name]['#access'] = FALSE;
}
}
}
}