How can I change the Class of SELECT fields that Joomla generates'

by GDP   Last Updated April 15, 2018 13:10 PM

I've disable chosen.js so that all my <select> tags are plain HTML, but am so far unable to change the default class of inputbox to one of my choosing, (specificially from the Search Tools filters of my component page).

I've looked at a number of answers and tutorials about overriding forms, but I'm either not understanding the examples, or looking at the wrong kind of overrides.

Ultimately, I want to change the class of any <select> that is generated in libraries\cms\html\select.php. I've tried adding the path/file to my template, but can't get that to do it. I see that it's generating the field with $options as below, but I can't figure where THAT is being determined and supplied.

$options Array (
    [format.depth] => 0
    [format.eol] => 

    [format.indent] =>  
    [id] => filter_event_group_id
    [list.attr] => class="inputbox" onchange="this.form.submit()"
    [list.translate] => 
    [option.key] => value
    [option.text] => text
    [list.select] => 
)

My attempts at specifying it in the XML at List form field type are failing as well - the page just comes up blank, though that was a shot in the dark because my field is actually a SQL Form Field Type which apparently does NOT support the Class parameter like the Select does.

<field name="created_by" class="MyChosenClassname" type="sql"...`

So, the question is either how do I add this override to my template properly, or how do I specify the Class name to be used in the generated <select> tags?



Answers 1


You should just be able to add the class attribute to the XML field, like so:

<field name="foo" class="MYCLASS" type="list" label="My List">
    <option value="0">Option 1</option>
    <option value="1">Option 2</option>
</field>
Lodder
Lodder
March 16, 2018 12:14 PM

Related Questions


Subform inside modal

Updated September 21, 2017 13:10 PM

XML form related fields

Updated November 27, 2016 08:04 AM

Let JForm-Fields be dependent on eachother

Updated July 21, 2015 13:04 PM

Joomla 3 save multiple list custom field for component

Updated November 04, 2017 12:10 PM