1

I've created a custom content entity (generated via drupal console), I can add custom fields just fine via the cms.

What I'm try to do now is change the default label from 'Name' to 'Artwork Title'.

I've tried the following, but I'm not seeing the changes.

class EntryEntityForm extends ContentEntityForm {

      /**
       * {@inheritdoc}
       */
      public function buildForm(array $form, FormStateInterface $form_state) {
        $form = parent::buildForm($form, $form_state);

        $form['name']['widget']['#title'] = $this->t('Artwork Title');
        $form['name']['widget'][0]['#title'] = $this->t('Artwork Title');

        $entity = $this->entity;

        return $form;
      }
...
}

Can someone please point me in the right direction?

7

I managed to change the label using the following:

$form['name']['widget'][0]['value']['#title'] = $this->t('Artwork Title');

Hope this helps someone else.

| improve this answer | |
  • 1
    Thank you Janey! I spent 3 hours to find out where to change the label. – Henry Oct 17 '17 at 5:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.