2 JFormField issues

52 views
Skip to first unread message

stutteringp0et

unread,
Apr 19, 2012, 2:13:24 AM4/19/12
to Joomla! Platform Development
First, a simple bug in the JFormFieldColor field type. When inserting
2 or more color fields via XML form definition, the second and
subsequent fields are unusable. The first works fine, but when a
color is selected - the color hex is sent to all color fields in the
form. The second and subsequent color fields will display the
selector when clicked, but you can't select a color. Tested in 2.5.4
using Firefox and Chrome.

I've been using MooRainbow for a while in custom field types, and my
implementation works fine regardless of the number of color pickers in
the form. I'd be happy to send it to whoever is interested.

Second, is an issue/solution to JFormFieldList (and derivatives) which
prevents fields defined in an XML form definition with multiple="true"
from having multiple default values.

A single default value works fine:
<field type="list" name="test1" multiple="true" default="1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</field>

Multiple default values fails to select even a single value:
<field type="list" name="test1" multiple="true" default="1,3,5">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</field>

I found this strange, because if you pass CSV or an array as a value
in data, it works fine - but if the CSV is passed as the default from
XML it doesn't work at all.

So, my simple fix is to add 3 lines to the top of the genericlist
method in libraries/joomla/html/html/select.php:
if(preg_match('/multiple="multiple"/',$attribs) && !
is_array($selected)) {
$selected = explode(',',$selected);
}

It works fine for the list type, but I haven't tested the derivatives
yet.
Reply all
Reply to author
Forward
0 new messages