by
gem3 » Mon Jun 10, 2019 4:10 pm
Hello @KK,
I put my code.(I'm not good at Javascript. This works but I'm not sure this is right.)
Use case :
"block_type" is a selector for a block. Then onece block is selected, you should select block no. for selected block type. (I do not put all types, there are over 10 types.) Fields for block no. which not selected should be hidden. So I use conditional fields.
Note: This code is not in use, because if there more than two different types appears in records, it display strange in header and not showing active record of select-dropdown. So just take this sample is just sample codes for conditional fields. So it better to hack stacked-layout into not-stacked-layout using bootstarp class.(ex delete row, col-md-10 -> col-md-2 )
- Code: Select all
<cms:editable
order='20'
name="block_type"
label="Please select a block type."
opt_values='calltoaction | content | counter | features | footer'
opt_selected = 'calltoaction'
type='dropdown'
/>
<cms:func _into='is_show' block_type=''>
<cms:if block_type='calltoaction'>show<cms:else />hide</cms:if>
<cms:alt_js>
var var_block_type='calltoaction'
var $target_th = $form.find("th.k_element_block_selected_" + var_block_type);
var $target_td = $form.find("td.editable.k_element_block_selected_" + var_block_type);
if(block_type===var_block_type){
$target_th.show();
$target_td.show();
return 0;
}
else{
$target_th.hide();
$target_td.hide();
return 1;
}
</cms:alt_js>
</cms:func>
<cms:editable
order='110'
name="block_selected_calltoaction"
label="Please select a block No.(calltoaction)"
opt_values='01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15'
type='dropdown'
not_active=is_show
/>