In this file fapi_example/src/Form/BuildDemo.php,

 $form['actions']['rebuild'] = [
      '#type' => 'button',
      '#value' => 'Submit Rebuild',
      '#submit' => ['::rebuildFormSubmit'],
    ];

'#type' => 'button',
should be changed to
'#type' => 'submit',

if not,"rebuildFormSubmit" method will not be invoked

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fluxyster created an issue. See original summary.

nicorac’s picture

+1, thanks for it.
I've lost 2 hours to find out why my code doesn't work, then downloaded Examples module just to check if it has the same "issue" and... yes, it has ;)

I think 2 actions are needed:
- a fix to Examples module
- an update to Drupal core forms API documentation

Mile23’s picture

Priority: Critical » Major
FileSize
1.42 KB

Moving to major because it breaks the behavior but doesn't cause a crash.

Here's a fix. Please review.

Mile23’s picture

Status: Active » Needs review
Mile23’s picture

Also, based on #2, we should find/file a core issue to update the docs.

Mile23’s picture

Re-running the testbot.

  • Mile23 committed 01c3ee7 on 8.x-1.x
    Issue #2897097 by Mile23, brucelee1985: fapi module rebuild submit bug
    
Mile23’s picture

Status: Needs review » Fixed

And done. Thanks, folks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.