function ContextFormTrait::buildProvidedContextForm
Provides the form part for a 'provided' context parameter.
2 calls to ContextFormTrait::buildProvidedContextForm()
- ActionForm::form in src/
Form/ Expression/ ActionForm.php - Adds elements specific to the expression to the form.
- ConditionForm::form in src/
Form/ Expression/ ConditionForm.php - Adds elements specific to the expression to the form.
File
-
src/
Context/ Form/ ContextFormTrait.php, line 108
Class
- ContextFormTrait
- Provides form logic for handling contexts when configuring an expression.
Namespace
Drupal\rules\Context\FormCode
public function buildProvidedContextForm(array $form, FormStateInterface $form_state, $provides_name, ContextDefinitionInterface $provides_definition, array $configuration) {
if (isset($configuration['provides_mapping'][$provides_name])) {
$default_name = $configuration['provides_mapping'][$provides_name];
}
else {
$default_name = $provides_name;
}
$form['provides'][$provides_name] = [
'#type' => 'fieldset',
'#title' => $provides_definition->getLabel(),
];
$form['provides'][$provides_name]['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Variable name'),
'#description' => $this->t('The variable name must contain only lowercase letters, numbers, and underscores and must be unique in the current scope.'),
'#required' => TRUE,
'#default_value' => $default_name,
];
return $form;
}