You are here

public function HeartbeatUpdateFeedForm::buildForm in Heartbeat 8

Throws

\Drupal\heartbeat\Controller\HeartbeatAjaxException

Overrides FormInterface::buildForm

1 call to HeartbeatUpdateFeedForm::buildForm()
HeartbeatUpdateFeedForm::submitForm in src/Form/HeartbeatUpdateFeedForm.php
Form submission handler.

File

src/Form/HeartbeatUpdateFeedForm.php, line 54

Class

HeartbeatUpdateFeedForm
Class HeartbeatUpdateFeedForm.

Namespace

Drupal\heartbeat\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  //    $request = \Drupal::request();
  //    if ($this->triggered) {
  //      $this->triggered = false;
  //      throw new \Drupal\heartbeat\Controller\HeartbeatAjaxException($this);
  //    }

  //TODO this should be changed to library
  $form['#attached']['libraries'][] = 'heartbeat/heartbeat';
  $form['timestamp'] = [
    '#type' => 'textfield',
    '#value' => t('Update Feeds'),
    '#ajax' => [
      'url' => Url::fromUri('internal:/heartbeat/form/heartbeat_update_feed'),
      'callback' => '::updateFeedCommand',
      'options' => array(
        'query' => array(
          'callback' => 'updateFeedCommand',
        ),
      ),
      'progress' => array(
        'type' => 'none,',
      ),
    ],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
    '#ajax' => [
      'callback' => '::updateFeedCommand',
      'url' => Url::fromUri('internal:/heartbeat/form/heartbeat_update_feed'),
      'progress' => array(
        'type' => 'none,',
      ),
      'options' => array(
        'query' => array(
          'callback' => 'updateFeedCommand',
        ),
      ),
    ],
  ];

  //    $this->prepareAjaxForm($form);
  return $form;
}