Hello,
I am trying to use FC select field as chained Select fields with jQuery plugin. Please check
www.appelsiini.net/projects/chained
Current FC Select field Structure:
Code:
<select id="custom_ucfield21" name="custom[ucfield21]" class="use_select2_lib required select2-offscreen" required="required" aria-required="true" tabindex="-1" style="background-color: rgb(255, 255, 255);">
<option value="">SELECT</option>
<option value="1">YES</option>
<option value="2">NO</option>
</select>
To be able to use select field as
chained, we need to
add class name(s) for each option.
Code:
<select id="mark" name="mark">
<option value="">--</option>
<option value="bmw">BMW</option>
<option value="audi">Audi</option>
</select>
<select id="series" name="series">
<option value="">--</option>
<option value="series-3" class="bmw">3 series</option>
<option value="series-5" class="bmw">5 series</option>
<option value="series-6" class="bmw">6 series</option>
<option value="a3" class="audi">A3</option>
<option value="a4" class="audi">A4</option>
<option value="a5" class="audi">A5</option>
</select>
Means that we have to add Field Elements in 3-columned.
value1::label1::classname1%% value2::label2::classname2%%
and classname should accept
spaces.
Current FC select field only accept 2-columned, so maybe we just create
new textarea parameter to add list of classnames.
Now, to make them as chained, we need to add jQuery.
So we need
new textarea parameter for this.
Code:
<script type="text/javascript" charset="utf-8">
$(function(){
$("#series").chained("#mark");
});
</script>
I know that you are very busy but I see people talking about this feature in forum. So If you don't mind, please tell me how to add class name for each option.
Not sure, somewhere around here I guess.
Code:
// Create field's HTML display for item form
// Display as drop-down select
$options = array();
if ($usefirstoption) $options[] = JHTML::_('select.option', '', JText::_($firstoptiontext));
foreach ($elements as $element) {
$options[] = JHTML::_('select.option', $element->value, JText::_($element->text));
}
$field->html = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $field->value, $elementid);
Hope you can add this feature with a little effort in near future!
Regards,
Brandon