Good way to add classes to form input and label elements directly?
Good way to add classes to form input and label elements directly?
bfarkas
Posts: 181Questions: 48Answers: 0
Trying to do some advanced styling, i.e. turn a checkbox into a switch like element which is supported in the foundation framework but relies on adding classes to the input/label elements directly.
I don;t see a way to do this in the current setup of editor unless I am overlooking something?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can get the
input
element usingfield().input()
and modify it from there. That means you need to do it after the form has been initialised.If you want to do it globally, the way to do it would be with a field type plug-in.
Allan
Thanks, I think I ended up at a similar route, but just regular javascript and DOM elements:
This added a class to the input, a class to the label, and added content into the label area.