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

I am working on some sort of a CRM with Couch.
One of the section is the "Proposal" clonable pages. I need to be able to convert a Proposal to a "Contract", which is another clonable page section.

What I did is this:

Code: Select all

    <p>Convertir en contrat ?</p>
    <cms:input name='submit' type="submit" class="button red" value="Oui, convertir en contrat" />

<cms:if k_success>



        $(function() {
            toastr.success("Proposition convertie en contrat avec succès", "Succès!", { // TODO: localize
                "positionClass": "toast-top-right",
                "showDuration": "250",
                "hideDuration": "250",
                "timeOut": "3500",
                "extendedTimeOut": "500",
                "icon": '<cms:show_icon 'check' />'
    <cms:db_delete masterpage=k_template_name page_id=k_page_id />

    <cms:redirect "http://localhost:8888/edit/?o=propositions.php&q=list"  />"



Everything is working perfectly fine, except that "contact_dropdown" region, used in the "db_persist_form" section of the code.
That region is a relation region. It is linked with another page, showing the clients name.
You can see the "sous_total" region too here, which is a regular text field. It is correctly being copied in the converted proposal to a contract. But for some reasons, it seems like "Relation" regions are not being "cloned".

Any idea why?

Same seems to be happening with repeatable regions. It's not being copied to the new page.

Thanks a lot
Relation requires enumerating id of the page. Samples:

Code: Select all
relation_editable = some_destination_page_id
relation_editable = '11'
relation_editable = '11, 22,33' (in case of multiple relations - type `many`)

While @trendoman correctly pointed out the right syntax, allow me to try and explain why your original code is not working. I think this could be helpful.

Let us take the following statement (which is working) -
Code: Select all

If I were to write it in the following way instead -
Code: Select all
sous_total="<cms:show sous_total />"

the above would still work just the same. Point here being that specifying a bare variable is equivalent to 'showing' that variable.

Now consider what happens if I try showing the 'relation' region (anywhere) -
Code: Select all
<cms:show contact_dropdown />

You'll get a blank.
That is because the relation value is a complex variable and requires the help of another tag to display it properly (for type relation these are the <cms:related_pages> and <cms:reverse_related_pages> tags, as you know).

Same applies to repeatable regions. Using a simple cms:show to display them will only yield a blank (we use the auxiliary tag <cms:show_repeatable> to properly display the values).

That should explain why simply using the variable name won't work with cms:db_persist/cms:db_persist_form.

As to what would work depends on what those regions expect their inputs to be when explicitly provided via cms:db_persist/cms:db_persist_form.

For relations, as @trendoman showed, it is a comma-separated string of page ID.
For repeatable-regions, I am afraid, but explicitly providing its value is not supported yet.

To programmatically get the comma-separated IDs, you may set the 'ids_only' parameter to '1' in <cms:pages>, <cms:related_pages> and <cms:reverse_related_pages> e.g.
Code: Select all
<cms:related_pages 'artist_albums' ids_only='1' />

Note that the tag above is used in a self-closing manner.

Hope this helps.
Thanks for the help guys.

I cannot find a way to make it work though.
Everything is set in a custom admin theme for the proposal page.
Converting the Proposal into a Contract is done clicking a button in the edit page of a clonable page in the admin.

I want to make sure that whatever is saved in that clonable page, it copied in the newly created contract based on that page content.

The fields are almost identical in the Proposal page template and the Contract page. That's why I used:

Code: Select all


(same field names on both sides of the equal sign)
Because I basically want it to duplicate the Proposal page, but inside the Contract page (some fields won't be the same, but most of them will).

Also, I know you said it's not quite possible for Repeatable regions, but is there any way to achieve this at all? Maybe using custom code? I really need to be able to do this.

Thanks a lot!
Sorry to bump this topic. I would really need help with this. This is my biggest project with this client, and I am confident everything can be done with Couch :)
As I already mentioned, it is not something that can be done using regular Couch tags (repeatable-region being the reason).
I think we'll have to fall back on using raw PHP to get things done.

I'll, however, need some time for that as I have got my hands full at the moment.
If you could wait for a few days, I'll try to figure out something.
Thanks a lot KK!
I can surely wait few days :)
Thanks so much for the great support.
7 posts Page 1 of 1

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests