I have a Matrix field that I am using for an address.
I have 5 columns in total
Address 1 - Text Address 2 - Text City - Text County - P&T Dropdown Postal Code - Text
I have City and County marked as required.
Now using the standard short field name in Safecracker will not output the fields how I want them formatted, so I am breaking them out.
For example,
I have the following when it comes to address one...
<input type="hidden" name="address[row_order][]" value="row_new_0" />
<input type="text" class="span8" name="address[row_new_0][col_id_4]" />
<span class="help-block">Address (first line)</span>
This works fine for all the text fields, but I am not sure about how the best way to display the P&T dropdown field.
I am using a P&T dropdown, as it allows me to utilise option groups, which I am using like so
England
-county 1
-county 2
-etc
Scotland
- and so on...
Now the only way I have found to output this in safecracker, is to write out every option.
<select class="span6" name="address[row_new_0][col_id_6]">
<option value="" selected="selected">Select your county</option>
<optgroup label="England">
<option value="Avon">Avon</option>
<option value="Bedfordshire">Bedfordshire</option>
...
</optgroup>
</select>
The problem with this is that it does not seem to validate. If I leave the select unchanged, it doesn't throw up the "required" error.
Another issue is that if I do complete the required fields, but make other errors on the form, when submitted, it does not remember the values I entered. Presumably this is due to it not have a value="something"
- but I am not sure what 'something' should be.
Any help appreciated!