getTestFieldType example

    $this->createField();

    $this->dateFormatter = $this->container->get('date.formatter');
  }

  /** * Creates a date test field. */
  protected function createField() {
    $field_name = mb_strtolower($this->randomMachineName());
    $field_label = Unicode::ucfirst(mb_strtolower($this->randomMachineName()));
    $type = $this->getTestFieldType();
    $widget_type = $formatter_type = $type . '_default';

    $this->fieldStorage = FieldStorageConfig::create([
      'field_name' => $field_name,
      'entity_type' => 'entity_test',
      'type' => $type,
      'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATE],
    ]);
    $this->fieldStorage->save();
    $this->field = FieldConfig::create([
      'field_storage' => $this->fieldStorage,
      
Home | Imprint | This part of the site doesn't use cookies.