public function TransactionForm::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 EntityForm::buildForm
File
- src/
Form/ TransactionForm.php, line 19
Class
- TransactionForm
- Form controller for the transaction entity.
Namespace
Drupal\transaction\FormCode
public function buildForm(array $form, FormStateInterface $form_state, ContentEntityInterface $target_entity = NULL) {
/** @var \Drupal\transaction\TransactionInterface $transaction */
$transaction = $this->entity;
// Set the target entity in the transaction.
if ($target_entity) {
$transaction
->setTargetEntity($target_entity);
}
$form = parent::buildForm($form, $form_state);
// Grouping status & authoring in tabs.
$form['advanced'] = [
'#type' => 'vertical_tabs',
'#weight' => 99,
];
$form['transaction_authoring'] = [
'#type' => 'details',
'#title' => $this
->t('Transaction authoring'),
'#open' => TRUE,
'#group' => 'advanced',
];
$form['uid']['#group'] = 'transaction_authoring';
$form['created']['#group'] = 'transaction_authoring';
// Ask for execution.
if ($transaction
->getType()
->getOption('execution') == TransactionTypeInterface::EXECUTION_ASK && $transaction
->isPending()) {
$form['execute'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Execute'),
'#weight' => 99,
];
}
return $form;
}