In my Drupal 8 custom module,
I have a form accessible with link '/myform', which once submitted redirected to '/user/1' page.
But the issue is this message '"Current time is ". time()' is shown on both('/myform' and '/user/1') the pages.
class DecisionConfigForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
drupal_set_message("Current time is ". time() , 'warning'); // Even I tried with $repeat= FALSE
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state->setRedirect($route_name, $route_params); //say, /user/1 page
}
}
Comments
Comment #5
jeroentThis is by design. BuildForm is called to build the form structure. If we don’t call the build form method, it won’t be possible to build the form array (first parameter the submitForm method).
Feel free to reopen if you still think this is a bug.