public function PaymentFormConfigurationForm::buildForm in Payment 8.2
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 ConfigFormBase::buildForm
File
- modules/
payment_form/ src/ Plugin/ Payment/ Type/ PaymentFormConfigurationForm.php, line 82
Class
- PaymentFormConfigurationForm
- Provides the configuration form for the payment_form payment type plugin.
Namespace
Drupal\payment_form\Plugin\Payment\TypeCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('payment_form.payment_type');
$form['plugin_selector'] = $this
->getPluginSelector($form_state)
->buildSelectorForm([], $form_state);
$limit_allowed_plugins_id = Html::getUniqueId('limit_allowed_plugins');
$form['limit_allowed_plugins'] = [
'#default_value' => $config
->get('limit_allowed_plugins'),
'#id' => $limit_allowed_plugins_id,
'#title' => $this
->t('Limit allowed payment methods'),
'#type' => 'checkbox',
];
$allowed_plugin_ids = $config
->get('allowed_plugin_ids');
$options = [];
foreach ($this->paymentMethodManager
->getDefinitions() as $definition) {
$options[$definition['id']] = $definition['label'];
}
$form['allowed_plugin_ids'] = [
'#default_value' => $allowed_plugin_ids,
'#multiple' => TRUE,
'#options' => $options,
'#states' => [
'visible' => [
'#' . $limit_allowed_plugins_id => [
'checked' => TRUE,
],
],
],
'#title' => $this
->t('Allowed payment methods'),
'#type' => 'select',
];
return $form + parent::buildForm($form, $form_state);
}