Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295783

Allow #type 'button' that aren't form submits

$
0
0

Problem/Motivation

As per this very old forum discussion, creating form element buttons with a type of anything other than type="submit" is not possible - type="submit" is hard-coded.

Steps to reproduce

Proposed resolution

Add an additional #submit_button key to #type button, defaulting to TRUE. When this is FALSE, remove the type=submit related logic from the output.

Remaining tasks

Create a failing functional test that the MR makes pass. If possible utilise one of the existing test forms. Also try to add the test to an existing test class.

Since this change affects the submit #type indirectly, update docblocks and comments on submit and button #types accordingly.

Create a new child issue: demonstrate the new #submit_button key in the examples project's form API module.

User interface changes

N/A

Introduced terminology

N/A

API changes

A new key '#submit_button' is added to the button form #type. The default value is TRUE. That preserves the current behaviour of the button #type for backward-compatibility reasons. However, if changed to FALSE, the button element will no longer submit when clicked. Clicking will not trigger a page refresh.

Data model changes

N/A

Release notes snippet

The change allows the developer to toggle off form submission functionality with one line of code and no need to resort to multi-line workarounds.


Viewing all articles
Browse latest Browse all 295783


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>