You are here

public function MortgageCalculatorJSForm::buildForm in Real Estate Mortgage Calculator 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/MortgageCalculatorJSForm.php, line 25

Class

MortgageCalculatorJSForm
MortgageCalculatorJSForm.

Namespace

Drupal\mortgage_calculator\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['loan_amount_2'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Price of Home'),
    '#size' => 10,
    '#maxlength' => 64,
  ];
  $form['mortgage_rate_2'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Mortgage Rate'),
    '#size' => 10,
    '#maxlength' => 64,
  ];
  $form['years_to_pay_2'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Years to Pay'),
    '#size' => 10,
    '#maxlength' => 64,
  ];
  $form['#executes_submit_callback'] = FALSE;
  $form['calculate_2'] = [
    '#type' => 'button',
    '#value' => $this
      ->t('Calculate'),
  ];
  $form['result_2'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Monthly Payment'),
    '#size' => 10,
    '#maxlength' => 64,
    '#attributes' => [
      'readonly' => [
        'readonly',
      ],
    ],
  ];

  // Attach js and required js libraries.
  $form['#attached']['library'][] = 'mortgage_calculator/mortgage_calculator_js';
  return $form;
}