Conditional Form Fields
Jamroom Developers
If you just want to show/hide fields depending on value you can add javascript to the form.
The field name will be the field's id, and the table row you want to show/hide is the parents parent. There is more to do if it's an image field etc, but for most field types this:
$_options = array(
'show' => 'show',
'hide' => 'hide'
);
$_tmp = array(
'name' => 'mymodule_show_hide',
'label' => 'show or hide the checkbox field',
'help' => 'help!',
'type' => 'select',
'options' => $_options,
'required' => false
);
jrCore_form_field_create($_tmp);
$_tmp = array(
'name' => 'mymodule_target',
'label' => 'check this',
'help' => 'check this help',
'type' => 'checkbox',
'default' => 'off',
'validate' => 'onoff'
);
jrCore_form_field_create($_tmp);
$_tmp = array('
if ($("#mymodule_show_hide").val() == "hide") {
$("#mymodule_target").parent().parent().hide();
$("#mymodule_target").val("off");
}
$("#mymodule_show_hide").change(function(){
if ($(this).val() == "hide") {
$("#mymodule_target").parent().parent().hide();
$("#mymodule_target").val("off");
} else {
$("#mymodule_target").parent().parent().show();
}
});
');
jrCore_create_page_element('javascript_ready_function',$_tmp);