I've faced with the task where is need to add custom CSS classes to "submit" button of the form. I saw that other form elements have a great feature to place own CSS classes to both wrapper and element. It's really useful because can save our time instead of writing preprocesses or overriding templates.
So, basically i suggest to add the same option for "submit" button.

Comments

alweb created an issue. See original summary.

alphawebgroup’s picture

StatusFileSize
new2.88 KB
alphawebgroup’s picture

StatusFileSize
new3.7 KB
alphawebgroup’s picture

jrockowitz’s picture

I feel adding custom classes to the submit button is too specific of a tweak. It also lead too adding custom classes to the draft, previous, next, and preview buttons.

I think a better approach is to add some classes to all the submit buttons like yamlform-button, yamlform-button--submit, etc... and then allow the form's classes to be customized.

To customize the form's classes it should mirror how element's support custom classes using a globally defined list of class names.

All patches are going to require tests.

@alweb are you up for this task. I am also okay implementing this in the next few weeks.

jrockowitz’s picture

For a consistent UX and UI I think custom styles, classes, and even properties should be supported at the form level. Custom form properties could be used to set a form's target, prefix, suffix, etc...

jrockowitz’s picture

Title: Add an option to set custom CSS classes for the "submit" button » Add custom classes, styles, and properties to form settings and class name to submit buttons

Updating issue title.

jrockowitz’s picture

Title: Add custom classes, styles, and properties to form settings and class name to submit buttons » Add custom classes, styles, and properties to form settings and class names to submit buttons
jrockowitz’s picture

Assigned: Unassigned » jrockowitz

I am going to start working on this issue. I will create branch so that you can track my progress.

jrockowitz’s picture

Below are the buttons classes that I am adding...

  • .yamlform-button--submit
  • .yamlform-button--previous
  • .yamlform-button--next
  • .yamlform-button--preview
  • .yamlform-button--draft

  • jrockowitz committed a8a872c on 2823918-custom-form-classes
    Issue #2823918 by alweb: Add custom classes, styles, and properties to...

  • jrockowitz committed ba8fb84 on 2823918-custom-form-classes
    Issue #2823918 by alweb: Add custom classes, styles, and properties to...
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new13.62 KB

  • jrockowitz committed 1c92b98 on 8.x-1.x
    Issue #2823918 by alweb, jrockowitz: Add custom classes, styles, and...
jrockowitz’s picture

Status: Needs review » Fixed
alphawebgroup’s picture

Hi Jacob.
Thank you for your update.
but it looks like you've implemented adding predefined classes only.
in my case I need an option to add my own css class to the button, i.e. .btn-orange or .btn-blue

alphawebgroup’s picture

Status: Fixed » Needs work
alphawebgroup’s picture

aaah, sorry, haven't realize you've change the title of this issue...
so basically, form classes and attributes is completely another stuff...
by my simple task I just need to add my own css classes to the submit button.
should I open new ticket for submit buttons then?

alphawebgroup’s picture

Status: Needs work » Fixed
jrockowitz’s picture

@alweb Adding custom classes to each submit button is too specific of a feature and should be handled in separate contrib or custom module.

If you create a contrib (or sandbox) module I will add a link to it from http://yamlform.io/support/installation/#additional-contrib-modules

alphawebgroup’s picture

hm) I thought it's completely similar to the feature which allows change the label of the submit button...
If we can change the label of the button, why not add a custom css class to the same button?

jrockowitz’s picture

Status: Fixed » Postponed
Related issues: +#2815203: Allow for adding class to form submit button, form

I think it is too specific of a feature, especially because custom classes should be supported by all submit buttons.

I am seeing that other people are requesting it in the webform module's issue queue.

#2815203: Allow for adding class to form submit button, form

I am reopening this ticket, to allow more people to weigh in, but I am marking it as postponed.

alphawebgroup’s picture

Hi Jacob.

yes, exactly... this feature will allow us don't waste our modules/themes with form alters and preprocess functions. Especially in case when we have 10+ forms.

As for the custom form's CSS class - it's completely the same profit using for example one CSS selector for all / particular forms.
It's very useful by the way, i already use this feature. thank you.

alphawebgroup’s picture

one more vote for this feature - is using growing amount of CSS frameworks.
for example, my request is caused by MaterializeCSS framework. It already has pre-defined CSS selectors with many kinds of buttons.

as you wish yamlform to be the main form management module instead of webform, that means in the nearest future many people will be thankful for this feature, just because yamlform will allow them configure the forms with existing CSS selectors.

jrockowitz’s picture

MaterializeCSS buttons are really cool looking. http://materializecss.com/buttons.html

I think a more immediate task would be get the buttons wrapped in a customizable template so that the buttons can be altered to include icons (and CSS).

jrockowitz’s picture

I feel like I am doing everything I can to avoid adding support for custom classes to the UI. Still, I think the concept that a form's submit buttons should be easier to customize is very important, so created the below ticket.

#2826059: Create a dedicated template for YAML form actions

jrockowitz’s picture

Status: Postponed » Closed (won't fix)

I think customizing the submit buttons should be done at the theme layer and not customizable per form.

You should also look at #2826976: Allow CSS and JavaScript to be injected into a form. which gives you the ability add per form CSS & JS customization. You could even use JS to add custom classes to the submit buttons, if you really don't want to mess with yamlform-actions.html.

alphawebgroup’s picture

ok, thank you anyway... i understand you're busy with other issues, so, I can use custom patches in my composer.json to solve this for me, not a problem.

jrockowitz’s picture

Status: Closed (won't fix) » Active

I just completed a refactoring of attribute handling for forms and elements and it has made it much easier for me support styling buttons, so I am re-opening this ticket.

  • jrockowitz committed 1c92b98 on 2823918-button-attributes
    Issue #2823918 by alweb, jrockowitz: Add custom classes, styles, and...

  • jrockowitz committed aa8a58b on 2823918-button-attributes
    Issue #2823918 by alweb, jrockowitz: Add custom classes, styles, and...

  • jrockowitz committed 9b8e6d7 on 2823918-button-attributes
    Issue #2823918 by alweb, jrockowitz: Add custom classes, styles, and...
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new149.74 KB
jrockowitz’s picture

StatusFileSize
new2.33 MB

Below is a screenshot of the new buttons settings.

Status: Needs review » Needs work

The last submitted patch, 33: add_custom_classes-2823918-33.patch, failed testing.

  • jrockowitz committed bd15efb on 2823918-button-attributes
    Issue #2823918 by jrockowitz, alweb: Add custom classes, styles, and...
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new150.32 KB

  • jrockowitz committed 3b23ca2 on 8.x-1.x
    Issue #2823918 by jrockowitz, alweb: Add custom classes, styles, and...
jrockowitz’s picture

Status: Needs review » Fixed

  • jrockowitz committed 1c92b98 on 2823918-button-attributes
    Issue #2823918 by alweb, jrockowitz: Add custom classes, styles, and...
  • jrockowitz committed 9b8e6d7 on 2823918-button-attributes
    Issue #2823918 by alweb, jrockowitz: Add custom classes, styles, and...
  • jrockowitz committed aa8a58b on 2823918-button-attributes
    Issue #2823918 by alweb, jrockowitz: Add custom classes, styles, and...

Status: Fixed » Closed (fixed)

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