Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
Good Evening Couchies!

I have successfully made a DataBound form to submit content to my clonable page ( fruit.php ).

My question is : How can i edit my submited fruit from databound too?

I have tried to submit totally same content, but it shown duplicate.

Any suggest?

Thx!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
Hi,

Editing via DBF requires two changes to what you've already used -
1. setting the 'mode' parameter to 'edit'
2. setting the 'page_id' parameter to the ID of the page being edited e.g. as follows
<cms:form
masterpage=k_member_template
mode='edit'
page_id=k_page_id
enctype="multipart/form-data"
method='post'
anchor='0'
>

You can find a real-life example in the 'profile.php' file that is part of the sample files of 'members' module (viewtopic.php?f=5&t=8063).

Hope this helps.
KK wrote: Hi,

Editing via DBF requires two changes to what you've already used -
1. setting the 'mode' parameter to 'edit'
2. setting the 'page_id' parameter to the ID of the page being edited e.g. as follows
<cms:form
masterpage=k_member_template
mode='edit'
page_id=k_page_id
enctype="multipart/form-data"
method='post'
anchor='0'
>

You can find a real-life example in the 'profile.php' file that is part of the sample files of 'members' module (viewtopic.php?f=5&t=8063).

Hope this helps.


Ok Thx For reply KK !
It works! :D

but, how can i automaticly fetch the page id?
i have page :

- fruit.php (the main clonable page)

- fruit_list.php (list of all clonable fruit page) - [ with a "Add New Fruit" & "Edit Fruit" button, then i link each button with the page bellow ]

- addnew_fruit.php (the databound form)

- edit_fruit.php (i create this to edit databound form)

now, i manually put the page id there. i means, if i want to edit pageid 13, i create "edit_fruit13.php" page, and put " mode='edit' k_page_id='13' ".

any suggest? :?
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
We can use only a single template for editing all cloned pages.
This we can do by supplying it the id of the page to edit as querystring parameter (i.e. though its URL).

So, for example, in your case if we use a single non-clonable template named 'edit_fruit.php' for editing fruits, the template can be invoked as -
http://yoursite.com/edit_fruit.php?id=23
or
http://yoursite.com/edit_fruit.php?id=42

where we use a querystring parameter named 'id' to supply the page id to edit.

We can craft this URL automatically. Since you are using 'fruit_list.php' to list all fruits, you'd have a cms:pages loop in it. We can place the following code to add an EDIT link to all pages being listed -
Code: Select all
<cms:pages masterpage='fruit.php' >
    ...
    ...
    <a href="<cms:link 'edit_fruit.php' />?id=<cms:show k_page_id />">EDIT</a> <br/>
</cms:pages>


So now we can invoke the 'edit_fruit.php' template with the page id to edit.
Here is how we retrieve that ID in 'edit_fruit.php' and then use it within the DBF -

If you are using Couch v1.4.5, use the following code -
Code: Select all
<!-- get the 'id' parameter from querystring -->
<cms:set my_page_id="<cms:gpc method='get' var='id' />"/>

<!-- make sure it is a valid value before using it -->
<cms:if "<cms:validate my_page_id validator='non_zero_integer' />">
    <cms:form
        masterpage='fruit.php'
        mode='edit'
        page_id=my_page_id
        enctype="multipart/form-data"
        method='post'
        anchor='0'
    >
        ...
        ...
       
    </cms:form>
</cms:if>

If, however, you are using an older version of Couch, we'll have to use a bit of PHP to validate the id being passed. Here is the equivalent of the code above -
Code: Select all
<!-- get the 'id' parameter from querystring -->
<cms:set my_page_id="<cms:gpc method='get' var='id' />"/>

<!-- make sure it is a valid value before using it -->
<cms:php>
    global $FUNCS, $CTX;
    if( !$FUNCS->is_non_zero_natural($CTX->get('my_page_id')) ){
        $CTX->set( 'my_page_id', '' );
    }
</cms:php>

<cms:if my_page_id >
    <cms:form
        masterpage='fruit.php'
        mode='edit'
        page_id=my_page_id
        enctype="multipart/form-data"
        method='post'
        anchor='0'
    >
        ...
        ...
       
    </cms:form>
</cms:if>

Hope this helps.
Thx KK !!!


Image

You know what i mean with that picture :lol: !

Thx Again!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
You are always welcome :)
KK, another question.

Now im facing the repeatable regions. I have add the repeatable regions to my databound page, the page shown the 4 fields of my repeatable regions, and the "add new row" button. But when i click the add new row, theres nothin happ, also when i input someth on that fields, the fields are empty when i check the admin panel. Is it need another modification, or is there any code, or i cant handle repeatable regions from databound?
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
We can use repeatable-regions in Databound-forms but that'd need including all JS/CSS files that repeatable-regions addon depends on within your template's HTML.

Please try adding the following to your template
Code: Select all
<head>
    <script type="text/javascript" src="<cms:show k_admin_link/>includes/mootools-core-1.4.5.js"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>includes/mootools-more-1.4.0.1.js"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>addons/nicedit/nicEdit.js?kver=<cms:show k_cms_build />"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>addons/repeatable/tablegear/tablegear.js?kver=<cms:show k_cms_build />"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>addons/repeatable/dg-arrange-table-rows/dg-arrange-table-rows.js?kver=<cms:show k_cms_build />"></script>
   
    <link rel="stylesheet" href="<cms:show k_admin_link/>addons/repeatable/tablegear/tablegear.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />
    <link rel="stylesheet" href="<cms:show k_admin_link/>addons/repeatable/dg-arrange-table-rows/dg-arrange-table-rows.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />
    <link rel="stylesheet" href="<cms:show k_admin_link/>addons/data-bound-form/datetime.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />
   
</head>

One possible problem you could still run into is that the code above includes 'mootools' library.
If your existing HTML already makes use of JQuery, this could lead to conflicts.
You'll then need to use the no_conflict setting of JQuery (i am sure you'll manage that).

Hope this helps.

EDIT:
The code above was for the older v1.4.x version of Couch. For the newer v2.0, please see -
viewtopic.php?f=4&t=10784#p27418
KK wrote: We can use repeatable-regions in Databound-forms but that'd need including all JS/CSS files that repeatable-regions addon depends on within your template's HTML.

Please try adding the following to your template
Code: Select all
<head>
    <script type="text/javascript" src="<cms:show k_admin_link/>includes/mootools-core-1.4.5.js"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>includes/mootools-more-1.4.0.1.js"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>addons/nicedit/nicEdit.js?kver=<cms:show k_cms_build />"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>addons/repeatable/tablegear/tablegear.js?kver=<cms:show k_cms_build />"></script>
    <script type="text/javascript" src="<cms:show k_admin_link/>addons/repeatable/dg-arrange-table-rows/dg-arrange-table-rows.js?kver=<cms:show k_cms_build />"></script>
   
    <link rel="stylesheet" href="<cms:show k_admin_link/>addons/repeatable/tablegear/tablegear.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />
    <link rel="stylesheet" href="<cms:show k_admin_link/>addons/repeatable/dg-arrange-table-rows/dg-arrange-table-rows.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />
    <link rel="stylesheet" href="<cms:show k_admin_link/>addons/data-bound-form/datetime.css?kver=<cms:show k_cms_build />" type="text/css" media="screen" />
   
</head>

One possible problem you could still run into is that the code above includes 'mootools' library.
If your existing HTML already makes use of JQuery, this could lead to conflicts.
You'll then need to use the no_conflict setting of JQuery (i am sure you'll manage that).

Hope this helps.


Thx again KK! it works! Yes im use noconflict, and it was hard when apply the noconflict :D

can i ask another question? :lol: (i hope i can)

I use inline edit with editable type="text", when i visit the inline edit the border shown, but there is no save tab & button. is it only for editable type textarea and rich? thx

edit : it works when i use popup edit. but still cant save the change when use inline edit.
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
can i ask another question? :lol:

But of course :)
I'd appreciate, however, if you could create a new thread for questions that are not a continuation of the original subject (the last two questions would fit the description) - makes them searchable, and hence more useful, to others. Hope you don't mind my request :)

Replying to your last question -
A 'text' type works just as fine as other types.
Can you please ensure that the following condition mentioned in the docs is met? -
IMP: Please notice that the inline_edit tag is always added as a parameter to a block-level HTML element.

You need to place the inline tag within <H1> etc.
Please try and see.

Thanks.
11 posts Page 1 of 2
cron