public function ModuleNameForm::form in Module Builder 8.3
Gets the actual form array to be built.
Overrides ComponentSectionForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ ModuleNameForm.php, line 38
Class
- ModuleNameForm
- Form for editing basic information, and also for adding new module entities.
Namespace
Drupal\module_builder\FormCode
public function form(array $form, FormStateInterface $form_state) {
$module = $this->entity;
// The name.
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Readable name'),
'#maxlength' => 255,
'#default_value' => isset($module->name) ? $module->name : '',
'#description' => $this
->t("The form of the module name that appears in the UI."),
'#required' => TRUE,
);
// The machine name.
$form['id'] = array(
'#type' => 'machine_name',
'#title' => $this
->t('Name'),
'#description' => $this
->t("The module's machine name, used in function and file names. May only contain lowercase letters, numbers, and underscores."),
'#maxlength' => 32,
'#default_value' => $module->id,
'#machine_name' => array(
'exists' => '\\Drupal\\module_builder\\Entity\\ModuleBuilderModule::load',
'source' => [
'name',
],
'standalone' => TRUE,
),
);
$form = parent::form($form, $form_state);
return $form;
}