Comments (5)
Previously reported here: #203
from govuk-formbuilder.
Thanks @frankieroberto - I'm keen for this to remain in the form builder as that's where most people would expect to find it. As it's actually causing problems that affect users it'll definitely be resolved - I'm not totally sure of the best way yet, but it'll probably be either:
- a
#govuk_submit_button
helper on the builder that renders a button - an argument (with corresponding config to set the default) that can be supplied to the existing
#govuk_submit
, which toggles betweeninput
andbutton
I'd assume that if we're rendering a <button>
element we'd want to be able to provide its contents with a block of HTML in addition to a string, and #govuk_submit
already uses its block to wrap itself in a button group, so maybe the former would make more sense.
from govuk-formbuilder.
I had a really quick play with the idea and think it might be the way forward.
Adding a button:
param to #govuk_submit
that defaults to the configuration's default setting - true
to always render buttons by default and false
to use inputs.
This allows buttons to be configured by the developer if one or the other is needed for a odd circumstance.
Also, the button
arg could take a proc (as seen elsewhere in the library), that would allow the contents of the <button>
element to be set with any arbitrary HTML.
Unless I've missed something here it feels like a sensible approach that'll work for most people. I'm hesitant to just switch over from input
to button
en masse as it'll mean people will need to update their tests.
from govuk-formbuilder.
Happy to keep it in the formbuilder, although I think it’d be good to make it available outside of a formbuilder as a global helper too, given that it doesn’t need to bind to the form model.
I don't think we have any reason to also support the <input type="submit">
, especially with that bug.
Given how prevalent form buttons are, it might be sensible to think through how to enable users to switch to the button in the least painful way.
Options could be:
- make
govuk_submit
output a button, but do this in a major version release as it might break some existing tests which expect an input. However this might require the least downstream changes. - create a new
govuk_button
orgovuk_submit_button
method and/or helper. - mark
govuk_submit
as deprecated for a version.
Agree with supporting block content as well as a string. One of the advantages of the <button>
element is that it can support additional markup (although it's rarely needed).
We should also make sure that both the button and the link-styled-as-button support both the prevent-double-click
option and start-button
option – and that both include the data-module="govuk-button"
attribute.
from govuk-formbuilder.
If people are using the capybara method click_button
in their tests, then that shouldn’t require any code changes, as that already supports both <input type="button">
and <button>
.
from govuk-formbuilder.
Related Issues (20)
- Date Handling Errors HOT 6
- Displaying all errors for child attributes HOT 2
- Not able to check a govuk_radio_button value HOT 5
- Use input=date HOT 2
- It's not possible to make radio labels a regular font weight when a hint is provided HOT 1
- Setting a JSON object as an HTML attribute on form elements doesn't work HOT 1
- Idea: let hint text for date fields contain dynamic dates HOT 1
- HTML safe markup is ignored even when providing a custom presenter HOT 1
- Change hint element to div instead of span tag HOT 1
- Remove `pattern` attribute from date field
- Conditional revealed question values HOT 4
- Support hint for fieldset HOT 3
- Labels in radio button collections that include hint text are unexpectedly emboldened
- Possible improvement: localisation of nested attributes HOT 6
- Hrefs on `.govuk-error-summary__list` item links do not match IDs on `.govuk-error-message` elements HOT 2
- Can we release a patch version that supports the latest version of Pagy?
- Select does not show errors from Rails' belongs_to presence validation HOT 6
- Version 4.0.0
- Support inverse button style HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from govuk-formbuilder.