You are here

public function MiniDonationForm::buildForm in Commerce Donate 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/MiniDonationForm.php, line 87

Class

MiniDonationForm
Provides the donation form.

Namespace

Drupal\commerce_donate\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['amount'] = [
    '#type' => 'number',
    '#title' => t('Enter the amount'),
    '#required' => TRUE,
    '#placeholder' => t('Enter amount'),
  ];
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Donate Today'),
    '#button_type' => 'primary',
  ];
  $form['frequency'] = [
    '#type' => 'radios',
    '#options' => [
      'onetime' => t('Single Donation'),
      'monthly' => t('Monthly Donation'),
    ],
    '#default_value' => 'onetime',
    '#required' => TRUE,
  ];
  return $form;
}