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

With databound tutorial I learn how to create and submit data using below code
Code: Select all
<cms:form 
            masterpage=k_template_name
            mode='create'
            enctype='multipart/form-data'
            method='post'
            anchor='0'
            >


Now I like to using Edit/Modify data like
Code: Select all
<cms:form 
            masterpage=k_template_name
            mode='edit'
            enctype='multipart/form-data'
            method='post'
            anchor='0'
            >

but there require page id . well I found it from member module in working condition

Code: Select all
<cms:form 
            masterpage=k_template_name
            mode='edit'
            enctype='multipart/form-data'
            method='post'
            page_id=k_member_id
            anchor='0'
            >


Now my question to you that
1) without using member module how I can generate Page_id from a databound clone page ?
2) Is there any details tutorial about mode='edit' in couch, kindly give me the link.

Thanking you
Subhamoy
Hi Subhamoy,

1) without using member module how I can generate Page_id from a databound clone page ?
Every cloned page in Couch, whichever template it might belong to, has a 'k_page_id' variable (just like it has a 'k_page_name' or 'k_page_title' variable). You can see it if you place a <cms:dump /> tag within a cms:pages loop or in a page-view.

2) Is there any details tutorial about mode='edit' in couch, kindly give me the link
This advanced tutorial makes extensive use of 'edit' mode -
http://www.couchcms.com/docs/advanced-tutorial/

Hope it helps.
Thank you KK for your help.

Can I add Create and Edit on a same template ?

I just tried it but I don't when I login as a super admin my template run successfully , but when I logout and trying to access page it show

ERROR: Tag "form" - page_id required

Below code is for create

Code: Select all
 <cms:set submit_success="<cms:get_flash 'submit_success' />" />
        <cms:if submit_success >
            <div class="alert alert-success"><strong>Success:</strong> Your application has been submitted. Press F5 for refresh</div>
        </cms:if>
<cms:form
            masterpage=k_template_name
            mode='create'
            enctype='multipart/form-data'
            method='post'
            anchor='0'
            >
           
            <cms:if k_success >
           
                <cms:check_spam email=frm_email />
               
                <cms:db_persist_form
                    _invalidate_cache='0'
                    _auto_title='1'
                />
               
                <cms:if k_success >
                    <cms:set_flash name='submit_success' value='1' />
                    <cms:redirect k_page_link />
                </cms:if>
            </cms:if>
           
            <cms:if k_error >
                <div class="alert alert-danger"><strong>Error:</strong>
                    <cms:each k_error >
                        <br><cms:show item />
                    </cms:each>
                </div>
            </cms:if>
           
         <div class="form-group <cms:if k_error_first_name || k_error_last_name >has-error</cms:if>">
            <label class="control-label" for="first-name">Enter New Item </label>
            <div class="row">
               <div class="col-xs-6">
                  <cms:input class="form-control" id="particular" name="particular" placeholder="Enter Particular" type="bound" value="" />
               </div>
               <div class="col-xs-6">
                  <cms:input class="form-control" id="amount" name="amount" placeholder="Amount" type="bound" value="" />
               </div>
               <div class="col-xs-6">
                  <cms:input class="form-control" id="amounttwo" name="amounttwo" placeholder="Amount" type="bound" value="" />
               </div>   
            </div>
         </div>      
         
           
            <cms:if "<cms:not submit_success />" >
                <button class="btn btn-primary" type="submit">Add/Submit  Item</button>
            </cms:if>
           
      </cms:form>


and I used this code for show and edit

Code: Select all
                        
                  <cms:form class="form-horizontal" id="dynamic"
                        masterpage=k_template_name
                        mode='edit'
                        page_id=k_page_id
                        enctype="multipart/form-data"
                        method='post'
                        anchor='0'>
       
                        <cms:if k_success >
                        <cms:db_persist_form />

                        <cms:set_flash name='success_msg' value='1' />
                        <cms:redirect k_page_link />
                        </cms:if> 
       
                        <cms:if k_error >
                        <font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
                        </cms:if>
                            <table class="table">
                                <thead>
                                    <tr>
                                        <td style="width:  5%" class="text-center"><label>No.</label></td>
                                        <td style="width: 45%"class="text-center"><label>Particulars</label></td>
                                        <td style="width: 15%" class="text-center"><label>Amount</label></td>
                               <td style="width: 15%" class="text-center"><label>Amount</label></td>
                                     
                                        <td style="width:  5%" class="text-center"><label>Remove</label></td>
                                    </tr>
                                </thead>
                        
               
                        
      <cms:pages masterpage='application.php' orderby='cell'  order='asc' >
                                <tbody id="itemlist">
                                    <tr>
                                        <td><input type="bound" class="form-control  input-sm text-right" data-cell="A1"  data-format="0"></td>
                                        <td><input id="particular" name="particular" type="bound" class="form-control input-sm"  value="<cms:show particular />" data-cell="B1"></td>
                                        <td><input id="amount" name="amount" type="bound" class="form-control input-sm text-right"  value="<cms:show amount />"data-cell="<cms:show cell />" data-format="$ 0,0.00"></td>
                              <td><input id="amounttwo" name="amounttwo" type="bound" class="form-control input-sm text-right"  value="<cms:show amounttwo />"data-cell="<cms:show cell />" data-format="$ 0,0.00"></td>
                                       
                                        <td class="text-center"><button class="btn-remove btn btn-sm btn-danger"><i class="fa fa-times fa-fw"></i></button></td>
                                    </tr>
                                   
                                </tbody>  </cms:pages>     
                                <tfoot>
                                    <tr style="margin-top:30px">
                                        <td>
                                           
                                        </td>
                                        <td align="right">
                                            <label for="total">Total</u></label>                                 
                                        </td>
                               <td align="right">
                                            <u black;”="" solid="" border-bottom:4px="" style="border-bottom:3px solid black;”></u><b><u Style="><label data-cell="E1" data-format="$ 0,0.00" data-formula="SUM(CALX1+CALX3+CALX5+CALX7+CALX9+CALX11+CALX13+CALX15+CALX17+CALX19+CALX21+CALX23+CALX25 )"></u></label>                                 
                                        </td>
                               <td align="right">
                                           <u black;”="" solid="" border-bottom:4px="" style="border-bottom:3px solid black;”></u><b><u Style="> <label data-cell="F1" data-format="$ 0,0.00" data-formula="SUM(CALX2+CALX4+CALX6+CALX8+CALX10+CALX12+CALX14+CALX16+CALX18+CALX20+CALX22+CALX24+CALX26)"></u></label>                                 
                                        </td>                                     
                                        <td>&nbsp;</td>
                                    </tr>
                           <tr style="margin-top:30px">
                                        <td align="right">                                                                             
                                        </td>
                                        <td align="right">                                                                             
                                        </td>
                               <td align="right">
                                              <label for="total">Cash in hand</u></label>                              
                                        </td>
                               <td align="right">
                                           <u black;”="" solid="" border-bottom:4px="" style="border-bottom:3px solid black;”></u><b><u Style="> <label data-cell="G1" data-format="$ 0,0.00" data-formula="SUM(E1-F1)"></u></label>                                 
                                        </td>                                     
                                        <td>&nbsp;</td>
                                    </tr>
                                </tfoot>
                            </table>
                     <input type="submit" name="submit" value="Save"/>   
       
    </cms:form> 


Page successfully run when only I used

Code: Select all
 <cms:form 
                        masterpage=k_member_template
                        mode='edit'
                        page_id=k_member_id
                        enctype="multipart/form-data"
                        method='post'
                        anchor='0'>
The error indicates that k_page_id is empty and thus no value has been specified for the page_id parameter. You have set the mode to 'edit', but not specified which page to edit... Place a <cms:dump/> before the form to confirm this.

As @KK mentioned, k_page_id will be available in a cms:pages loop or page-view.
4 posts Page 1 of 1