Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
Hello,

I made a simple template Using Conditional fields as repeatable-regions.

When using with stacked_layout='1', labels of repeatable-fields hide.
But when using with stacked_layout='0', labels of repeatable-fields don't hide.

How can I fix this ?

Thank you in advance.
Hi,

This will require using our own custom JS to hide/show the columns.
Please see the conversation here ('alt_js' is the key) - viewtopic.php?f=5&t=11512&start=20#p33731

Basically, we place a 'dummy' hidden field wired to the controlling field(s). Our JS associated with this dummy field then performs the hide/show operations.

Let me know if it helps.
Thank you, @KK.

I will try tomorrow, then I will report the result.
Hello.

I made codes with alt_js and works well. (I don't use a dummy field)
But without stacked_layout, conditional fields are not so effective.

Thank you.
Could you share your code here please?
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
    />
6 posts Page 1 of 1