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

I am trying to add a table, inside a group (tab), containing results and displaying data from other pages.
So first thing I did was creating a "cms:field" on the page I want to display that table, and attributing a "group" to that field.
Inside that field, I have pasted my HTML code. To display a table similar to what is shown in the admin panel, I used the following code:

Code: Select all
<cms:pages masterpage="notifications/contrat-conf.php">
  <tr>
        <td class="col-date"><span style="fill:green;"><cms:show_icon 'check' />Contract <strong>WORKER</strong></td>
        <td class="col-date"><cms:related_pages 'notification_contenu' ><cms:show k_page_title /></cms:related_pages></td>
        <td class="col-date"><cms:show date_envoi_contrat_conf/></td>
        <td class="col-date"><cms:show destinataire_01/></td>
        <td class="col-actions">
          <a class="icon tt" href="<cms:admin_link />" title="Modifier">
          <svg class="i"><use xlink:href="<cms:show k_site_link />edit/theme/_system/assets/open-iconic.svg#pencil"></use></svg>
          </a>
          <a class="icon tt" href="<cms:show k_page_link/>" title="Voir">
          <cms:show_icon 'magnifying-glass' />
          </a>
        </td>
  </tr>
</cms:pages>


It's working perfectly.
But my issue is that I wanted to add the "trash" icon in the "col-actions" column, and allowing the user to delete an entry directly from that section.

So I added this line to the "col-actions" column section (last "a" tag):

Code: Select all
       <td class="col-actions">
          <a class="icon tt" href="<cms:admin_link />" title="Modifier">
          <svg class="i"><use xlink:href="<cms:show k_site_link />edit/theme/_system/assets/open-iconic.svg#pencil"></use></svg>
          </a>
          <a class="icon tt" href="<cms:show k_page_link/>" title="Voir">
          <cms:show_icon 'magnifying-glass' />
          </a>
          <a class="icon tt" href="<cms:show k_page_link/>" title="Voir">
          <cms:show_icon 'magnifying-glass' />
          </a>
          <a href="<cms:db_delete masterpage=k_template_name page_id=k_page_id />">
          <cms:show_icon 'trash' />
          </a>
        </td>


But it's not working.
So I thought maybe I could add this instead of that "a" tag (adding a form inside the table):

Code: Select all
<cms:form method='post'>
    <cms:input name='submit' type="submit" id="delete" class="btn btn-primary" style="background-color:#CD0000;margin-top:15px;" value="Delete" />
        <cms:if k_success >
                    <cms:db_delete masterpage=k_template_name page_id=k_page_id />
                    <cms:redirect "<cms:admin_link />?o=notifications%2Fcontrat-client-remerciement.php&q=list" />
        </cms:if>
</cms:form>


Which I think technically would work, but from what I understand, you cannot nest forms in HTML. Which makes sense because pressing that "Submit" button would try to submit multiple form at once. (I guess?)

Any idea how I could make use of <cms:form> in this case?
I am trying to add a "delete" button here, but I also tried to add (in another page) a text field with a submit button that would generate a page using db_persist_form on another page, from inside that entry admin page. Once again, I cannot use "db_persist_form" because it must be inside a form, and the whole admin edit page is already a form.

Thanks!
Any ideas? Thanks!
@larin555, you may try using a custom admin snippet for your particular template (as explained here - viewtopic.php?f=2&t=10438&p=25693#p25696) and then adding a *second* form immediately below the original form.

This way the two forms can be submitted independently.

Hope this helps. Do let me know how it goes.
Thanks KK.
But this will add a form under the main page form, right?
I was talking about adding forms inside some group/tabs in the main form.

Being able to generate pages/entries from the main form using db_persist_form.
Forms, as you know, cannot be nested. So, there is no way we can add a form within the existing form.

For what you are trying to achieve, you'll have to use AJAX to call your custom routine in the background.
5 posts Page 1 of 1