public BlockContentTypeForm::form(array $form, FormStateInterface $form_state)
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- core/modules/block_content/src/BlockContentTypeForm.php, line 18
Class
- BlockContentTypeForm
- Base form for category edit forms.
Namespace
Drupal\block_content
Code
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/* @var \Drupal\block_content\BlockContentTypeInterface $block_type */
$block_type = $this->entity;
if ($this->operation == 'add') {
$form['#title'] = $this->t('Add custom block type');
}
else {
$form['#title'] = $this->t('Edit %label custom block type', array('%label' => $block_type->label()));
}
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Label'),
'#maxlength' => 255,
'#default_value' => $block_type->label(),
'#description' => t("Provide a label for this block type to help identify it in the administration pages."),
'#required' => TRUE,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $block_type->id(),
'#machine_name' => array(
'exists' => '\Drupal\block_content\Entity\BlockContentType::load',
),
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
);
$form['description'] = array(
'#type' => 'textarea',
'#default_value' => $block_type->getDescription(),
'#description' => t('Enter a description for this block type.'),
'#title' => t('Description'),
);
$form['revision'] = array(
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $block_type->shouldCreateNewRevision(),
'#description' => t('Create a new revision by default for this block type.'),
);
if ($this->moduleHandler->moduleExists('language')) {
$form['language'] = array(
'#type' => 'details',
'#title' => t('Language settings'),
'#group' => 'additional_settings',
);
$language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('block_content', $block_type->id());
$form['language']['language_configuration'] = array(
'#type' => 'language_configuration',
'#entity_information' => array(
'entity_type' => 'block_content',
'bundle' => $block_type->id(),
),
'#default_value' => $language_configuration,
);
$form['#submit'][] = 'language_configuration_element_submit';
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $this->protectBundleIdElement($form);
}
Please login to continue.