Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Is it possible to make a databound form that displays all pages in a certain folder in a dropdown, where the user can pick from and when he fills out the form, there isn't created a new cloned page, but adds to that existing selected cloned page's repeatable region?

Especially the adding to repeatable regions instead of creating a new cloned page is what bothers me the most, I guess I can figure out the rest myself.

This aside:
Why would I want to do it like this? Let me give you some more context. I would like to have an "Events" masterpage where the folders are "the events" and the cloned page represents an activity of that event. Inside there are repeatable regions with the subscriptions for that event's activity. So I could make a page event/foldername that would display a form where a user can pick an activity, fill in other details and submit. What is important is that the order of the subscriptions could be easily altered afterwards, that's why I think the repeatable regions would be the most interesting.

I also would like some fields that shouldn't be filled in on the front-end, only the back-end. We would like to receive the payment at the event itself, so we (admins at the entrance) would be able to keep track of payments, of course this shouldn't be filled in by the customer themselves. Is it possible to ignore fields in a databound form, or should I use something like a hidden field with a default value in the form?

By the way: I'm not asking for someone else to write the entire code, but I just would like to know if my idea would be possible so I could lay out the base structure before running in to much trouble.
Hi,

While repeatable_regions can be used in data-bound forms, one limitation is that they'll always need the GUI (i.e. the table with draggable rows) to be displayed in the form.

That is to say that, unlike all other types of regions, we cannot set a repeatable-region's value directly into cms:db_persist or cms:db_persist_from (please see viewtopic.php?f=4&t=8704).

So, I'm sorry, I don't think we'll be able to handle the scenario you mentioned.

As an alternative to repeatable-regions, if you could use simple cloned-pages then this would become possible. Perhaps you could give this alternative a rethink? You can easily use relations to relate 'activities' to 'events' cloned pages.

What is important is that the order of the subscriptions could be easily altered afterwards, that's why I think the repeatable regions would be the most interesting.
Even normal cloned-pages can now be reordered easily - please see viewtopic.php?f=8&t=9577

Replying to your other question -
Is it possible to ignore fields in a databound form, or should I use something like a hidden field with a default value in the form?

Sure. We can explicitly pass values to cms:db_persist or cms:db_persist_form. Please see the following for examples -
viewtopic.php?f=2&t=8235
viewtopic.php?f=2&t=8301

Hope it helps.
Thanks KK for the helpful reply. The downside to this is that we need to open up a cloned page every time a customer shows up, which would slow down the process (we usually have a lot of customers in a short time span, because most of the subscribers arrive in the morning).

Maybe I would be able to make a front-end page where only admins would have access to, so they can update the information, so I can make a list of forms (where each form that is bound to a cloned page is a single row) that display all the info in a table or something.
Would I be able to generate a list of forms from the already existing cloned pages?
I've got everything working now, except for one detail. On a specific event page I have a form for that event. I would like to have a dropdown for the related activities but only the ones belonging to the specific event page the user is on, now it shows all the activities, also the ones that don't belong to that particular event, which is confusing. How to solve this?
My current structure looks like this:

I have a structure that looks like this now:
events.php
Code: Select all
<cms:template title='Events' clonable='1'>
<!-- some fields that belong to the event over here -->
</cms:template>
<cms:if k_is_page >
   <cms:form method='post' anchor='0' masterpage='subscriptions.php'
                    mode='create' enctype='multipart/form-data'>
<!-- some other form stuff here -->
  <label>Activity:</label>
   <cms:input name="activity_subscription" type="text" type="bound" />
                    <br/>
</cms:form>
</cms:if>


activities.php
Code: Select all
<cms:template title='Activities' clonable='1'>
<!-- some fields that belong to the activity over here -->
<cms:editable type='relation' name='event_activity' masterpage='events.php' has='one' reverse_has='many' />
</cms:template>


subscriptions.php
Code: Select all
<cms:template title='Subscriptions' clonable='1'>
   <cms:editable type='relation' name='activity_subscription' masterpage='activities.php' has='one' reverse_has='many' />
</cms:template>
Could you please also share the code in events.php where you are listing all its activities in the dropdown (the one that, as you mentioned, is showing all activities instead of only the related ones)?

Thanks
I'm not sure what you mean, I don't have a dropdown anywhere else, only in the form.
I've used this code: but this is not working because it shows also activities of other events:
Code: Select all
 <label>Activity:</label>
   <cms:input name="activity_subscription" type="text" type="bound" />
                    <br/>

Would it be possible to get the values from nested related pages tags and then display it in the form then bind it to the cloned page?

However when I output this code it does seem to display the right values. Question is how I make a dropdown with those values, then bind it to activity_subscription?
Code: Select all
<cms:reverse_related_pages masterpage='activities.php'>
                            <cms:show k_page_name />
                        </cms:reverse_related_pages>
You have answered my question. Thanks.

Would it be possible to get the values from nested related pages tags and then display it in the form..

Sure. Instead of using 'activity_subscription' in a 'bound' manner, please try this -
Code: Select all
<cms:input
    name = 'my_activity_id'
    label= 'Activity'
    opt_values = "
        <cms:reverse_related_pages masterpage='activities.php'>
            | <cms:show k_page_title />=<cms:show k_page_id />
        </cms:reverse_related_pages>"
    type = 'dropdown'
/>

.. then bind it to the cloned page?

We can get the ID of the page selected in the dropdown above and explicitly supply it to cms:db_persist_form as follows -
Code: Select all
<cms:db_persist_form
    _invalidate_cache = '0'
    activity_subscription = frm_my_activity_id
/>

Does this help?
Yes, perfect! That's what I was looking for. I didn't really understand the purpose of the db_persist_form, but now it makes more sense. Thanks for the helpful reply!
8 posts Page 1 of 1