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

I'd like to create a cloned template with databound form but prefill the editables with the values from an existing cloned page.

Unfortunately the method as follows does not work:
Code: Select all
<cms:pages masterpage='app/data/anfragen.php' id=rt_id limit='1'>
   <cms:form
      masterpage='app/data/anfragen.php'
      mode='create'
      enctype='multipart/form-data'
      method='post'
      id='editAnfrage'
      >
      <cms:input type="bound" name="status" class="form-control" value=status/>
      ...
      ...
   </cms:form>
</cms:pages>

If it doesn't work, I would be forced to recreate all editables in a non bound form. This would mean practically a duplicate of the template definition and lead to possible errors if I modify the template later on because of duplicate code.

Any Idea how to solve this?

Regards,
Olliwalli
Hi,

This functionality is actually complex enough to warrant a separate addon of its own - viewtopic.php?f=8&t=11545. The mentioned addon, however, works only in the backend so, I don't think, would be of much help to you.

If you are not dealing with complex editable regions (e.g. repeatable, mosiac), you may try to duplicate the addon's working by doing this -
instead of binding to a new page (i.e. mode='create'), bind with the page to be copied (in 'edit' mode with 'page_id' set to the page in question). This way the form inputs will show up containing the existing data.

Upon saving the form, in the k_success block, instead of <cms:db_persist_form />, use <cms:db_persist /> (viewtopic.php?p=15104#p15104) - use it in 'create' mode to create a new page and explicitly set its fields using the data submitted through the form (i.e. use the 'frm_' variables).

This way you'll end creating a new page with data from an existing one.

Hope this helps.
Thanks very much for this idea! I think I will be able to solve with this hint.

Great Support!

Regards,
Olliwalli
3 posts Page 1 of 1
cron