WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

Return HTML from a Drupal 8 form

Submitted by barnettech on Wed, 02/13/2019 - 15:09
 'textfield',
    '#title' => 'Search it',
    '#size' => 40,
    '#maxlength' => 60,
    );
    if (!empty($form_state->get('mymarkup'))) {
      $form['mymarkup'] = array(
        '#markup' => 'there we are shalom from me to you',
      );
     }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Search'),
    );
    if ($form_state->getValue('user_search')) {
        dpm("form submitted");
    }
    dpm($form);
    // drupal_set_message("
" . print_r($form_state, TRUE) . "

");
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
// Validate the form values.

}

/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
dpm($form_state->getValue('user_search'));
$form_state->set('mymarkup', 'Your search has been completed');
$form_state->setRebuild(TRUE);
}

}