juergenweb / FrontendForms

A module for ProcessWire CMS to create and validate forms on the frontend easily using the Valitron library.
MIT License
15 stars 1 forks source link

Request: description <div> instead of <p> #12

Closed donatasben closed 2 months ago

donatasben commented 2 months ago

Hi, me again :)

I was trying to use some html markup for my field descriptions, but I noticed it always sets it in <p class="description"> which is not ideal if my description content comes with its own paragraph tags already.

Would it be possible to introduce some method to choose to use a <div> instead of <p> for descriptions? Or maybe I just haven't found it.

For now I did it by using $input->getLabel()->append($myDescriptionHtml), but it feels like a workaround rather than an option.

juergenweb commented 2 months ago

Hello @donatasben

No need to append or prepend something. You could change the tag with

$input->getLabel()->setTag('div);

You can do the same to all other elements of the form too, but the disadvantage is, that you have to add it to every element separately.

I guess I will add some new functions which will be added to the form object itself like

$form->setLabelTag('div');

or something like that so tags will be changed for all labels inside the form in this case. But the setTag() works for now. I have it on my list ;-)

juergenweb commented 2 months ago

Sorry, you want to change the description tag so you need to write

$input->getDescription()->setTag('div);

I close this issue for now. If it does not work as expected, please open this issue again.

donatasben commented 2 months ago

@juergenweb Great, this does solve my need perfectly! Thought there should be something already 😉 Thank you!

juergenweb commented 2 months ago

Hello @donatasben

Version 2.2.6 supports now changing the tags of the label, description, notes, error and success message globally, on per form base and even on each inputfield.

Read more here.

The best way is to set them globally inside the module configuration, so the settings will be used on all forms across the site.

You will find the new config fields inside "Settings for markup and styling" in the same tab where you can set the usage of a CSS framework (see image below - unfortunately it is in German, but I guess you know how it should work ;-))

Screenshot 2024-07-12 at 19-06-17 Module FrontendForms • webseite1 at