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

I have a DBF having fields of name, mobile and email. On the same page I have a list that displays the entries entered from the DBF.

ISSUE
After submitting the DBF I need to refresh the page again for the last entered data to be displayed in the list (tabular format).

TRYING TO ACHIEVE
I would want to refresh the list as soon as the DBF is submitted successfully so that the last entry is updated in the list (table format).

How can I achieve that?

My code is:
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Students' clonable='1'>
   <!-- k_page_title == Student Name -->
   <cms:editable name='smobile' label='Student Mobile Number' type='text' required='1' validator='exact_len=10 | non_negative_integer' order='1' />   
   <cms:editable name='semail' label='Student Email Id' type='text' required='1' validator='email' order='2' />
</cms:template>
<html>
   <head>
      <title>Students</title>
      <style>
         table > thead > tr > th,
         table > tbody > tr > td {
            padding: 5px 10px;
         }
         table > thead > tr > th {
            background-color: rgba(0,0,0,0.8);
            color: white;
         }
      </style>
   </head>

   <body>
      <h1>
         Students
      </h1>
      <hr>

      <!-- FORM -->
      <cms:set submit_success="<cms:get_flash 'submit_success' />" />
      <cms:if submit_success >
         <h4>Success: Your application has been submitted.</h4>
      </cms:if>
      <cms:form masterpage=k_template_name mode='create' enctype='multipart/form-data' method='post' anchor='0'>
         <cms:if k_success >
            <cms:db_persist_form
                 _invalidate_cache='0'
                 k_page_title=frm_k_page_title
                 k_page_name=random_name
             />
            <cms:if k_success>
               <cms:set_flash name='submit_success' value='1' />
               <cms:redirect url='<cms:link masterpage=k_template_name />' />
            </cms:if>
         </cms:if>
         <cms:if k_error >
            <div class="error">
               <cms:each k_error >
                  <br><cms:show item />
               </cms:each>
            </div>
         </cms:if>
         <table border='0'>
            <tr>
               <td>
                  <label for='k_page_title'>Student Full Name</label>
               </td>
               <td>
                  <cms:input name='k_page_title' type='bound' />
               </td>
            </tr>
            <tr>
               <td>
                  <label for='smobile'>Student Mobile Number</label>
               </td>
               <td>
                  <cms:input name='smobile' type='bound' />
               </td>
            </tr>
            <tr>
               <td>
                  <label for='semail'>Student Email</label>
               </td>
               <td>
                  <cms:input name='semail' type='bound' />
               </td>
            </tr>
            <tr>
               <td colspan="2">
                  <center>
                     <button type='submit'>
                        SAVE
                     </button>
                  </center>
               </td>
            </tr>
         </table>
      </cms:form>
      <!-- FORM -->

      <br>
      <hr>
      <br>
      
      <!-- Student List -->
      <table border='1' style="width: 90%; margin: auto;">
         <thead>
            <tr>
               <th width='10%' style="text-align: center;">
                  Student Id
               </th>
               <th width='50%' style="text-align: center;">
                  Full Name
               </th>
               <th width='15%' style="text-align: center;">
                  Mobile Number
               </th>
               <th width='25%' style="text-align: center;">
                  Email Id
               </th>
            </tr>
         </thead>
         <tbody>
            <cms:pages masterpage=k_template_name>
            <tr>
               <td style="text-align: center;">
                  <cms:show k_page_id />
               </td>
               <td>
                  <cms:show k_page_title />
               </td>
               <td style="text-align: center;">
                  <cms:show smobile />
               </td>
               <td style="text-align: center;">
                  <cms:show semail />
               </td>
            </tr>
            </cms:pages>
         </tbody>
      </table>
      <!-- Student List -->

   </body>
</html>
<?php COUCH::invoke(); ?>


Regards,
GenXCoders
Image
where innovation meets technology
The issue has been solved.

Thanks to KK sirs' post viewtopic.php?p=19579#p19579.

The use of show_future_entries='1' does the trick so my new code is:

Code: Select all
...
<cms:form...
    ...
    <cms:redirect k_page_link />
    ...
</cms:form>
...
...
<table>
    ...
    <cms:pages masterpage=k_template_name order='asc' show_future_entries='1'>
        ...
    </cms:pages>
</table>
...
Image
where innovation meets technology
2 posts Page 1 of 1