Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hi,

So, I know that it is recommended to use cloned pages instead of repeatable regions with data-bound forms, but say I absolutely had to use data-bound forms with a repeatable region. What kind of markup would I have to write, and how do I proceed?

My page structure is like this:

orders.php (clonable) --> order-item (repeatable-region)

And I want logged in users to be able to create cloned pages of orders.php with multiple order-item fields (repeatable) in each.

How would I go about this?

P.S: Coming back to Couch after almost 1-2 years, so I may be a bit rusty about the syntax, or new features, but please help me out here
@KK I really need your help right now. I've figured everything else out. Please tell me if there is a way to make a databound repeatable region
Sorry for the delay @mercurial.

Assuming you are using Couch v2.0, following is a sample template that will allow you to use repeatable-regions within a databound-form placed within it -
Code: Select all
<html>
    <head>
        <link rel="stylesheet" href="<cms:show k_admin_link/>addons/repeatable/tablegear/tablegear.css?v=<cms:show k_cms_build />" type="text/css" media="screen"/>
           
        <script src="<cms:show k_admin_link />includes/jquery-3.x.min.js?v=<cms:show k_cms_build />"></script>
        <script type="text/javascript" src="<cms:show k_admin_link/>addons/repeatable/jquery-ui.min.js?v=<cms:show k_cms_build />"></script>
        <script type="text/javascript" src="<cms:show k_admin_link/>addons/repeatable/tablegear/tablegear.js?v=<cms:show k_cms_build />"></script>
       
        <style>
            .select-caret{ display:none; }
        </style>
    </head>

    <body>

        <!-- databound form here -->


        <script type="text/javascript">
            //<![CDATA[
            <cms:admin_js />
            //]]>
        </script>
    </body>
</html>

As an example, suppose the name of the repeatable-region is 'my_repeatable', the following regular 'bound' input (defined within a DBF) should be sufficient to display the regions as they do in the admin-panel
Code: Select all
<cms:input type='bound' name='my_repeatable' />

Hope this helps.
Hi @KK

Thank you so much for the reply. However, I did exactly as you said. It worked for the most part, but the add row button does not work at all. The JS files are loaded properly from couch, but the chrome dev console throws the following errors:
Image
And, submitting without any values triggered the success message, but the cloned page wasn't added to the admin panel either.

What could be the issue? I tried digging around myself, but it's beyond me. Can you please help me?

Thank you so much again!
The sample code I posted is from a working template so it is tested code.
Please use it verbatim without any change whatsoever (just enclose it with the two required PHP statements) in a new template.
Add to it a simple DBF with only the bound repeatable-region.

It should work as it is working for me.
Please try it and let me know.
Hi @KK

The problem was with this line in the code you had posted:
Code: Select all
<script src="<cms:show k_admin_link />includes/jquery-3.x.min.js?v=<cms:show k_cms_build />"></script>


On replacing that with jQuery from another source, it's working properly. :D

Thank you so much!
You are welcome :)

On replacing that with jQuery from another source, it's working properly. :D

Pretty strange as that is the jquery used by the admin-panel itself.
Anyway, I am glad the problem is solved.
7 posts Page 1 of 1
cron