public function TransactionTypeCreationForm::buildForm in Transaction 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ TransactionTypeCreationForm.php, line 70
Class
- TransactionTypeCreationForm
- Provides the transaction type creation form.
Namespace
Drupal\transaction\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$entity_types = [];
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type instanceof ContentEntityTypeInterface) {
$entity_types[$entity_type_id] = $entity_type
->getLabel();
}
}
asort($entity_types);
$form['target_entity_type'] = [
'#type' => 'select',
'#title' => $this
->t('Target entity type'),
'#description' => $this
->t('The target entity type. This cannot be changed once the transaction type is created.'),
'#options' => $entity_types,
'#default_value' => 'node',
'#required' => TRUE,
];
$form['transactor'] = [
'#type' => 'radios',
'#title' => $this
->t('Transactor'),
'#description' => $this
->t('Select the plugin type that operates the transaction. This cannot be changed once the transaction type is created.'),
'#options' => [],
'#required' => TRUE,
];
foreach ($this->transactorManager
->getTransactors() as $id => $info) {
$form['transactor']['#options'][$id] = $info['title'];
$form['transactor'][$id]['#description'] = $info['description'];
}
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Continue'),
];
return $form;
}