I have created a safecracker form that has some fields that with show / hide depending on the previous filed selection. For example:

    for="med">Are you currently taking any prescribed medication?:</label>
    type="radio" name="med" value="Yes"{checked} id="med2"  />&nbsp;Yes</label><label><input
    type="radio" name="med" value="No"{checked} id="med1"  />&nbsp;No</label>

<div id="med">
     <label for="medication" class="required">Please detail:</label>    {field:medication}<br></div>   

This code will show the {field:medication} if the yes radio button is selected. I can't use the normal code provided in the safecracker example as each field option needs to have a different id for the jquery action.

Unfortunately the {checked} code does not save the radio option when the form is saved. I'd appreciate any advice. Thanks

2 Answers 2


You could use:

<input type="radio" name="my_field" value="Yes"{if med == 'Yes'}Checked{/if} />
<input type="radio" name="my_field" value="No"{if med == 'No'}Checked{/if} />

If you get problems saving a 'required' field, then try adding hidden inputs:

<input name="my_field" type="hidden" value=""/>
  • This helped me today.. Thanks for the reminder :D Commented May 10, 2013 at 16:13

This should be a comment rather than an answer but I can post better code examples here. So the example for using custom fields looks like:

  {if radio}
                    <label class="checkbox">{option_value}
                            <input type="radio" id="{field_name}" name="{field_name}" value="{option_value}"{checked}>

That includes IDs. Why can't you use that code?

  • Does the id on the example not output the same for both values? I need a different id for each value.
    – user579984
    Commented Jan 10, 2013 at 9:08
  • In that case you could do something like id="{field_name}_{option_value}".
    – Tyssen
    Commented Jan 10, 2013 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.