EckEntityTypeEditForm.php in Entity Construction Kit (ECK) 8
File
src/Form/EntityType/EckEntityTypeEditForm.php
View source
<?php
namespace Drupal\eck\Form\EntityType;
use Drupal\Core\Form\FormStateInterface;
class EckEntityTypeEditForm extends EckEntityTypeFormBase {
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = $this
->t('Update @type', [
'@type' => $this->entity
->label(),
]);
return $actions;
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$fieldStorage = $this->entityTypeManager
->getStorage($this->entity
->id());
$definitions = $this->entityFieldManager
->getBaseFieldDefinitions($this->entity
->id());
foreach ([
'title',
'created',
'changed',
'uid',
'status',
] as $field) {
if (isset($definitions[$field]) && $fieldStorage
->countFieldData($definitions[$field], TRUE)) {
$form['base_fields'][$field]['#disabled'] = TRUE;
}
}
return $form;
}
}