function RulesComponentFormBase::form
Overrides EntityForm::form
3 calls to RulesComponentFormBase::form()
- ReactionRuleAddForm::form in src/
Form/ ReactionRuleAddForm.php - Gets the actual form array to be built.
- ReactionRuleEditForm::form in src/
Form/ ReactionRuleEditForm.php - Gets the actual form array to be built.
- RulesComponentEditForm::form in src/
Form/ RulesComponentEditForm.php - Gets the actual form array to be built.
3 methods override RulesComponentFormBase::form()
- ReactionRuleAddForm::form in src/
Form/ ReactionRuleAddForm.php - Gets the actual form array to be built.
- ReactionRuleEditForm::form in src/
Form/ ReactionRuleEditForm.php - Gets the actual form array to be built.
- RulesComponentEditForm::form in src/
Form/ RulesComponentEditForm.php - Gets the actual form array to be built.
File
-
src/
Form/ RulesComponentFormBase.php, line 43
Class
- RulesComponentFormBase
- Provides the base form for rules add and edit forms.
Namespace
Drupal\rules\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form['#entity_builders'][] = '::entityTagsBuilder';
$form['settings'] = [
'#type' => 'details',
'#title' => $this->t('Settings'),
'#open' => $this->entity
->isNew(),
];
$form['settings']['label'] = [
'#type' => 'textfield',
'#description' => $this->t('Enter a name to be used to identify your component in the administrative interface.'),
'#title' => $this->t('Label'),
'#default_value' => $this->entity
->label(),
'#required' => TRUE,
];
$form['settings']['id'] = [
'#type' => 'machine_name',
'#description' => $this->t('A unique machine-readable name for your component. Can only contain lowercase letters, numbers, and underscores.'),
'#disabled' => !$this->entity
->isNew(),
'#default_value' => $this->entity
->id(),
'#machine_name' => [
'exists' => [
$this,
'exists',
],
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
'source' => [
'settings',
'label',
],
'error' => $this->t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'),
],
];
// @todo Enter a real tag field here.
$form['settings']['keywords'] = [
'#type' => 'textfield',
'#title' => $this->t('Tags'),
'#default_value' => implode(', ', $this->entity
->getTags()),
'#description' => $this->t('Enter a list of comma-separated keywords here; e.g., "notification, publishing". Tags are keywords used for filtering available components in the administration interface.'),
'#required' => FALSE,
];
$form['settings']['description'] = [
'#type' => 'textarea',
'#default_value' => $this->entity
->getDescription(),
'#description' => $this->t('Enter a description for this component, to help document what this component is intended to do.'),
'#title' => $this->t('Description'),
];
return parent::form($form, $form_state);
}