I'm using the Joomla radio button form field type and am having trouble with option values that are strings. I'm not sure if I'm doing something wrong or if there is a bug there.
So in my component form xml I have a field like...
<field
name="myfield"
type="radio"
buttons="true"
class="btn-group"
default="public"
label="label text"
description="description text"
hint="hint text">
<option value="public">Public</option>
<option value="registered">Registered</option>
</field>
But when I create a new item with the form that uses this, the default is not set correctly. Then when I save the item the "myfield" value is "1". This just seems to be a problem with the setting of the default really. If I select one of the options and save, then the string, for example "public", is saved. Then if I edit the item again it displays as "public".
So, as a quick breakdown...
- It saves the radio value string if it's set
- It loads a saved radio value string
- It does not pre-populate the default radio string on new items
I had a look at the layout file in "layouts/joomla/form/field/radio.php" and could see the default value coming through as 1, "public" as it should have been.
The field docs are good, but didn't really give specifics on if value had to be a number, however in the three examples on the doc it is https://docs.joomla.org/Radio_form_field_type
This is in a custom component on Joomla! 3.7.0.