/**
  * {@inheritdoc}
  */
 public function tableFields($bundles)
 {
     $fields = parent::tableFields($bundles);
     $fields['label']['label'] = t('Title');
     $fields['status'] = ['type' => 'field', 'label' => t('Status'), 'weight' => 100, 'display_options' => ['settings' => ['format' => 'custom', 'format_custom_true' => t('Active'), 'format_custom_false' => t('Inactive')]]];
     return $fields;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function entityForm(array $entity_form, FormStateInterface $form_state)
 {
     $entity_form = parent::entityForm($entity_form, $form_state);
     // Remove the "Revision log" textarea,  it can't be disabled in the
     // form display and doesn't make sense in the inline form context.
     $entity_form['revision_log']['#access'] = FALSE;
     return $entity_form;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public static function entityFormSubmit(&$entity_form, FormStateInterface $form_state)
 {
     parent::entityFormSubmit($entity_form, $form_state);
     /** @var \Drupal\media_entity\MediaInterface $entity */
     $entity = $entity_form['#entity'];
     // Make sure media thumbnail is set correctly.
     $entity->automaticallySetThumbnail();
     if ($entity_form['#save_entity']) {
         $entity->save();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getTableFields($bundles)
 {
     $table_fields = parent::getTableFields($bundles);
     $bundle = array_pop($bundles);
     $use_display_fields = FALSE;
     // If there is a entity view display 'table' use those fields.
     // @todo How to document to the end user this functionality?
     /** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $entity_view_display */
     if ($entity_view_display = $this->entityTypeManager->getStorage('entity_view_display')->load("field_collection_item.{$bundle}.table")) {
         foreach ($entity_view_display->getComponents() as $field_name => $component) {
             $use_display_fields = TRUE;
             $fields = $this->entityFieldManager->getFieldDefinitions('field_collection_item', $bundle);
             /** @var \Drupal\field\Entity\FieldConfig $field */
             $field = $fields[$field_name];
             $table_fields[$field_name] = ['type' => 'field', 'label' => $field->getLabel(), 'display_options' => ['settings' => $component['settings']]];
         }
     }
     if ($use_display_fields) {
         unset($table_fields['label']);
     } else {
         $table_fields['label']['label'] = $this->t('Item');
     }
     return $table_fields;
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function entityForm($entity_form, FormStateInterface $form_state)
 {
     $entity_form = parent::entityForm($entity_form, $form_state);
     $entity_form['#entity_builders'][] = [get_class($this), 'populateTitle'];
     return $entity_form;
 }
 /**
  * {@inheritdoc}
  */
 public function tableFields($bundles)
 {
     $fields = parent::tableFields($bundles);
     $fields['status'] = ['type' => 'field', 'label' => $this->t('Status'), 'weight' => 100, 'display_options' => array('settings' => array('format' => 'custom', 'format_custom_false' => $this->t('Unpublished'), 'format_custom_true' => $this->t('Published')))];
     return $fields;
 }
Пример #7
0
 /**
  * @dataProvider providerTestExtractArraySequence
  */
 public function testExtractArraySequence($array, $list, $expected) {
   $this->assertEquals($expected, EntityInlineForm::extractArraySequence($array, $list));
 }