Important announcements from CouchCMS team
37 posts Page 4 of 4
KK, is there a solution to following?

Controlling field is a checkbox. When superadmin clicked 'Yes' 2 other fields are conditionally displayed.
Superadmin is logging out. Admin logs in.
Admin must not be able to change controlling checkbox. Admin can only edit and save 2 visible conditional fields.
Admin must not see controlling field hidden via CSS, because it can not be changed by Admin.


Code: Select all
<cms:editable
    type='checkbox'
    name='has_usage_limit'
    label='Limit maximum applications?'
    opt_values='Yes'
    not_active=my_cond_test
/>

<cms:func _into='my_cond' has_usage_limit=''>
    <cms:if "<cms:is 'Yes' in=has_usage_limit />">show<cms:else />hide</cms:if>
</cms:func>

<cms:editable
     name='maximum_applications'
     label='How many times the Coupon can be used'
     desc='Completely disable Coupon by un-publishing this page'
     type='text'
     search_type='integer'
     validator='non_zero_integer'
     width='155'
     not_active=my_cond
/>


<cms:editable
     name='applications'
     label='How many times'
     type='checkbox'
     opt_values='Yes'
     not_active=my_cond
/>


I think this question can pop up some day. I have come to this quiz myself after experiments and don't yet have a solution.
Greetings!

I was working with Conditional Fields and have a doubt.

I have a dropdown "Delivery Parking".
If Delivery parking is "Yes"
Then, Show Delivery parking type editable and a check box (an editable) to confirm it is marked on the map
If confirmation is marked "Yes" show Leasing Office editable
Else if Delivery Parking is "No"
Then show Leasing Office editable

Can the else part be achieved? If yes then how?

Regards,
GenXCoders (Priya)
Image
where innovation meets technology
Hi,

Code: Select all
If Delivery parking is "Yes"
    Then, Show Delivery parking type editable and a check box (an editable) to confirm it is marked on the map
    If confirmation is marked "Yes"
        Then show Leasing Office editable
Else if Delivery Parking is "No"
    Then show Leasing Office editable

I think the 'Leasing Office editable' is the region that is bothering you.
From the pseudo-code above, following could be the logic (again, pseudo) attached to the region -
Code: Select all
If (Delivery Parking is "No") || (Delivery parking is "Yes" && confirmation is "Yes") 
    show
Else
    hide
End If

Hope this helps.
@KK Sir,
Thanks for the quick reply.

Yes Sir, The Leasing Office editable is bothering me because it needs to be shown in either condition, only that the condition needs to be marked before showing it. Also, if the condition is YES then Leasing Office editable needs to be shown only if Confirmation is also YES

My actual Code is:
Code: Select all
<!-- Part #1 -->
<cms:editable name="delivery_parking" label="Delivery Parking" type="dropdown" opt_values="Select =- | Yes | No" group="sow" required="1" not_active=cond_map_link_marking order="5" />
<cms:func _into='cond_delivery_parking' delivery_parking=''>
    <cms:if "<cms:is 'Yes' in=delivery_parking />">
        show
    <cms:else />
        hide
    </cms:if>
</cms:func>

<!-- Part #2 -->
<cms:editable name="delivery_parking_type" label="Delivery Parking Type" type="dropdown" opt_values="Select=- | Building wise | Common Parking | No Restriction | Specific Building" opt_selected="" group="sow" opt_selected="-" required="1" not_active=cond_delivery_parking order="6" />
<cms:editable type='checkbox' name='delivery_parking_type_marking' label='Delivery parking type marked on Map?' opt_values='Yes' order="4" required="1" not_active=cond_delivery_parking />
<cms:func _into='cond_delivery_parking_type_marking' delivery_parking_type_marking=''>
    <cms:if "<cms:is 'Yes' in=delivery_parking_type_marking />">
   show
    <cms:else />
   hide
    </cms:if>
</cms:func>

<!-- Part #3 -->
<cms:editable name="leasing_office" label="Leasing Office" type="dropdown" opt_values="Select =- | Yes | No" required="1" not_active=cond_delivery_parking_type_marking  />


Now what happens is that if i use checkbox for the "delivery_parking" editable, i get output but if i use dropdown i dont get any output.

An what I want to achieve is that:
If Part #1 is YES, show Part #2 and Part #3
Else If Part #1 is NO, show Part #3.
Image
where innovation meets technology
I had tried to provide a solution using pseudo-code.
Following is the same code in the form understood by Couch -
Code: Select all
    <!-- Part #1 -->
    <cms:editable name="delivery_parking" label="Delivery Parking" type="dropdown" opt_values="Select =- | Yes | No" group="sow" required="1" order="1" />


    <!-- Part #2 -->
    <cms:func _into='cond_delivery_parking' delivery_parking=''>
        <cms:if delivery_parking = 'Yes'>
            show
        <cms:else />
            hide
        </cms:if>
    </cms:func>
    <cms:editable name="delivery_parking_type" label="Delivery Parking Type" type="dropdown" opt_values="Select=- | Building wise | Common Parking | No Restriction | Specific Building" opt_selected="" group="sow" opt_selected="-" required="1" not_active=cond_delivery_parking order="2" />
    <cms:editable type='checkbox' name='delivery_parking_type_marking' label='Delivery parking type marked on Map?' opt_values='Yes' order="3" required="0" not_active=cond_delivery_parking />
   
    <!-- Part #3 -->
    <cms:func _into='cond_delivery_parking_type_marking' delivery_parking='' delivery_parking_type_marking=''>
        <cms:if delivery_parking = 'No' || (delivery_parking = 'Yes' && "<cms:is 'Yes' in=delivery_parking_type_marking />")>
            show
        <cms:else />
            hide
        </cms:if>
    </cms:func>
    <cms:editable name="leasing_office" label="Leasing Office" type="dropdown" opt_values="Select =- | Yes | No" required="1" order="4" not_active=cond_delivery_parking_type_marking  />

The 'order' of the regions needed to be tweaked as Couch expects all dependent regions to be physically situated *after* the controlling regions.

Also note that the "<cms:is" tag is required only for type 'checkbox' (type 'dropdown' can be checked using "=").

Hope this helps.
@KK Sir,

Also note that the "<cms:is" tag is required only for type 'checkbox' (type 'dropdown' can be checked using "=").

I was not aware about this.

Your sample code as always has helped me.

But I have now come to another issue:
Code: Select all
<cms:editable name="access_type" label="Access Type" type="dropdown" opt_values="Select =- | Blank=0 | Delivery=1 | Private=2" not_active=cond_num_of_entrances_marking group="sow" order="16" />
      <cms:func _into="cond_access_type" access_type=''>
         <cms:if (access_type != '0' && (access_type = '1' || access_type = '2'))>
            show
         <cms:else />
            hide
         </cms:if>
      </cms:func>

      <cms:editable name="gate" label="Gate" type="checkbox" opt_values="Yes" not_active=cond_access_type group="sow" order="17" />
      <cms:func _into="cond_gate" gate=''>
         <cms:if "<cms:is 'Yes' in=gate />" >
            show
         <cms:else />
            hide
         </cms:if>
      </cms:func>

      <cms:editable name="num_of_gates" label="Number of Gates" type="dropdown" opt_values="Select =- | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30" not_active=cond_gate group="sow" order="18" />
      <cms:func _into="cond_num_of_gates" num_of_gates=''>
         <cms:if num_of_gates ne '-'>
            show
         <cms:else />
            hide
         </cms:if>
      </cms:func>

      <cms:editable name="gate_type" label="Gate Type" type="dropdown" opt_values="Select =- | Gate | Lift Gate | Sliding Gate | Bollard" not_active=cond_num_of_gates group="sow" order="19" />
      <cms:func _into="cond_gate_type" access_type='' gate_type=''>
         <cms:if access_type = '0' || gate_type ne '-'>
            show
         <cms:else />
            hide
         </cms:if>
      </cms:func>

      <cms:editable name="locked_gate" label="Locked Gate" type="dropdown" opt_values="Select =- | Yes | No" not_active=cond_gate_type group="sow" order="20" />


Here, 'access_type' has values "Select =- | Blank=0 | Delivery=1 | Private=2".
I am trying to show 'locked_gate' if the access_type='0' (This does not work).
While on the other hand, if access_type='1' or access_type='2' I want to show "gate, num_of_gates, gate_type" (This Works)

How can I achieve this: I am trying to show 'locked_gate' if the access_type='0'?

Could you please guide me sir!

Regards,
GenXCoders
Image
where innovation meets technology
@KK Sir,
I found the issue. The div with the k_element_<editable_name> was misplaced by me, hence I was facing the issue.
Regards,
GenXCoders
Image
where innovation meets technology
37 posts Page 4 of 4
cron