0

I have a hook where I change label visibility on each field, however I'm not able to do it on fields with BaseFieldOverride (like "Authored by" and "Authored on"). Their fields are always hidden, but I want to have them displayed.

Example

my_module_form_alter(&$form, FormStateInterface $form_state) {
  $build_info = $form_state->getBuildInfo();
  $entity_form = $build_info['callback_object'];
  $entity = $entity_form->getEntity();
  $field_definitions = $entity->getFieldDefinitions();
  foreach($field_definitions as $field_name => $field) {
    // For some fields I will render them as display instead of as form field, like this
    $form[$field_name] = $source_field->view();
    // But for the once that have field definitions instances of BaseFieldOverride, I can't set the label to be put above.
  }
}
  • Can you post your code or which hook you use ? – berramou Nov 6 at 15:01
  • Sure, I've added it into the question now! – user11448 Nov 7 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.