2 years ago

#71127

test-img

Simon Janvier

Change input submit form control to button form control in Drupal 9 Forms API

I want to replace input submit form control by a button form control into Drupal 9 Forms API. It seems not to be standard because the type of the submit button seems to be hard coded into the Forms API. I can admit that there is some ways to customize the button by using configuration options but it is not enough for styling control correctly. My case is the following :

When I am styling forms, I need frequently to add some icons into buttons but this is not possible to use pseudo selectors ::before or ::after on submit input buttons. The workaround I have found consists to add a div wrapper around my button but it is no really easy to fix elements placement issues in responsive. This is because of this css styling limits that I want replace all input submit buttons by <button> controls and style them more easily.

I wand to do it without breaking Forms API and Ajax by changing form control type.

php

drupal

drupal-8

drupal-forms

drupal-9

0 Answers

Your Answer

Accepted video resources