Important announcements from CouchCMS team
50 posts Page 5 of 5
@genxcoders, as mentioned in the docs on Conditional fields (viewtopic.php?f=5&t=11512#p30702), you are free to use any Couch code in the conditional logic for the *backend* processing (i.e. server-side processing done by Couch when the form gets posted); however, for the frontend JS only a very limited subset of Couch tags and editable regions are supported. Namely, only type 'checkbox', 'radio' and 'dropdown' editable-regions are supported by the automatically generated JS.

As you can see, type 'relation' will not work when it comes to frontend hiding/showing of fields dependent on it is concerned.

As a workaround, you'll have to supply your own custom JS using <cms:alt_js> tags (as shown at the end of the post mentioned above).

That said, you mentioned -
I earlier was using type=dropdown, but then when a user adds a new value which is in relation then it will need to be added separately to the dropdown editable.

If type 'dropdown' suits you better, you can easily make it dynamic as shown here -
viewtopic.php?p=2483#p2483

Please try this second approach also and see if it helps.
@KK Sir.
Thanks for the response sir. I have tried the dropdown approach just today, and it seems to be fit as of where my current development is.
The cms:alt_js I happened to skip. So I will also give it a try.

Is there a better way to implement a user role based access?

Sir you had once mentioned (sorry I could not locate that PM/post), that some changes are on card for role based user access like in SugarCRM (screenshot). I feel such a module/add-on would be even more useful since it will give the customers a great control over there applications developed in CouchCMS. Any thoughts on this sir?

Regards,
GenXCoders (Aashish)
Image
where innovation meets technology
@KK, can conditional fields be used in the following scenario?

I would like to get multiple dropdowns with folders set to a depth of 1 that are conditioned by the previous selection.

The first dropdown would show the main folders
Second one would show the children of previous selection but also with a depth of 1
And so on so forth.
@aleksandru, what you are actually looking for is something like the 'Hierarchical Select' mentioned by @trendoman here -
viewtopic.php?f=2&t=12504#p35036

Unfortunately though, we don't yet have a feature like that I am sorry.
KK wrote: @aleksandru, what you are actually looking for is something like the 'Hierarchical Select' mentioned by @trendoman here -
viewtopic.php?f=2&t=12504#p35036

Unfortunately though, we don't yet have a feature like that I am sorry.


Got it, thank you.
I used a work-around with Javascript after dumping all the hierarchy of the folders and asigning levels to them :)
@aleksandru
Great :)
Wonder if you'd be willing to share your code with us here on the forum?
I am sure it'd be useful for many.

Thanks.
KK wrote: @aleksandru
Great :)
Wonder if you'd be willing to share your code with us here on the forum?
I am sure it'd be useful for many.

Thanks.


@KK,
What I actually ended up doing is using QueryStrings and conditional statements while limiting the folders to a depth of 1 and making use of childof to take the parent from the query string if it is available.

As it is right now I am actually updating one single dropdown but it can easily be changed to show/hide multiple dropdowns.

I found this setup quite easy and useful in my case since I am using it on the front-end and not on the admin panel.


Code: Select all
<cms:set q_client = "<cms:gpc 'q_client' />" />
<cms:set q_project = "<cms:gpc 'q_project' />" />
<cms:set q_phase = "<cms:gpc 'q_phase' />" />
<cms:set q_start_link = "<cms:link masterpage='used_here.php' />" />

    <cms:if q_project>
      <label>Select a phase</label>
      <select name="clients" class="dropdown">
           <cms:folders masterpage="projects.php" hierarchical="1" order="desc" childof=q_project depth='1'>
            <option value="<cms:add_querystring q_start_link "q_client=<cms:show q_client />&q_project=<cms:show q_project />&q_phase=<cms:show k_folder_name />" />"><cms:show k_folder_title /></option>
            </cms:folders>
      </select>
    <cms:else />
        <cms:if q_client >
            <label>Select a project</label>
            <select name="clients" class="dropdown">
                <cms:folders masterpage="projects.php" hierarchical="1" order="desc" childof=q_client depth='1'>
                    <option value="<cms:add_querystring k_page_link "q_client=<cms:show q_client />&q_project=<cms:show k_folder_name />" />"><cms:show k_folder_title /></option>
                </cms:folders>
            </select>
        <cms:else />
            <label>Select a client</label>
            <select name="clients" class="dropdown">
                <cms:folders masterpage="projects.php" hierarchical="1" order="desc" depth="1">
                    <option value="<cms:add_querystring k_page_link "q_client=<cms:show k_folder_name />" />"><cms:show k_folder_title /></option>
                </cms:folders>
            </select>
        </cms:if>
    </cms:if>
Thank you, @aleksandru :)
KK wrote: Thank you, @aleksandru :)


@KK,

Let me ask you just as a curiosity, could this be also implemented in the admin panel ?
Maybe with the use of snippets ? I am not sure at this point if querystrings work with the admin panel :-?
aleksandru wrote: @KK,

Let me ask you just as a curiosity, could this be also implemented in the admin panel ?
Maybe with the use of snippets ? I am not sure at this point if querystrings work with the admin panel :-?


Query strings work with admin panel. Also dropdown field's opt_values can be fully dynamic and depend on query string parameter. Instead of k_page_link, admin-panel's base link (to which we add qs) would be k_route_link and actual link with entire qs would be k_qs_link.

I suggest to not reply or comment here, but open a new topic for any further discussion. ☺

My Documentation, Addons, Functions.
Join COUCH:TALK telegram channel
50 posts Page 5 of 5
cron