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

I like to input page id and submit it, after that I can Edit my data bound form others field with this page id ?

Code: Select all
<table>
<form action="" method="post">
<tr>
<td> Name: </td><td><input type="text" name="name"></td>
</tr>

<tr>
<td><input name="submit" type="submit" /></td></tr>

</form>
</table>

<?php
  if (isset($_POST['submit'])) {
    $NAME = $_POST["name"];   
   echo "Name is = ". $NAME .'</br>';   
  }
?>


Code: Select all

<cms:pages masterpage='student/student_view.php'  >
    <cms:set name = k_page_id 'global' /> 
</cms:pages>


<cms:form
   class="form-horizontal"
    masterpage='student/student_view.php'      
    mode='edit'
   page_id=name
    enctype='multipart/form-data'
    method='post'



Subhamoy
site.com/my-template.php?mode=edit&id=5

Code: Select all
<cms:set mode="<cms:gpc 'mode' />" scope='global' />
<cms:set id="<cms:gpc 'id' />"  />
<cms:if mode='edit' && id >
   <cms:embed 'edit-form.html' />
</cms:if>


Code: Select all
<cms:pages masterpage='student/student_view.php' id=id >
<cms:form
   class="form-horizontal"
    masterpage=k_template_name     
    mode=mode
    page_id=k_page_id
....
</cms:pages>


Code: Select all
<cms:pages masterpage='student/student_view.php' >
<cms:show k_page_title /> - <a href="<cms:add_querystring k_page_link "mode=edit&id=<cms:show k_page_id />" />" >Edit </a>
</cms:pages>


Code: Select all
<cms:form .. 
     <cms:if k_success && frm_name >
          <cms:set page_exists = "<cms:pages masterpage='student/student_view.php' id=frm_name ids_only='1' />" scope='parent' />
           <cms:if page_exists >
               <cms:redirect url="<cms:add_querystring "<cms:link masterpage='student/student_view.php' />"  "mode=edit&id=<cms:show frm_name />" />
            <cms:else /><cms:ignore>If page with id does not exist</cms:ignore>
                <cms:redirect url="<cms:link masterpage='student/student_view.php' />" />
            </cms:if >
     </cms:if><cms:ignore>/ k_success</cms:ignore>       
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Thanks @trendoman for your quick reply with code.
Its fine with a list of page_id link page. when I click a link it will redirect to the page with page Id and id.

but I needed a page_id input field with a submit button. I configure it like this

in student_page_id_submit.php
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:form method="post">
   <cms:if k_success >
      <cms:redirect "student_edit.php?name=<cms:show frm_name />" />
   </cms:if>
   
   <cms:if k_error >
      <h3>Failed to submit form</h3>
      <cms:each k_error >
         <cms:show item /><br>
      </cms:each>
   </cms:if>
   
   Your Name: <cms:input type="text" size="10" name="name" required='1' /><br />
   

   <cms:input name="submit" type="submit" value="Send" />
</cms:form>
<?php COUCH::invoke(); ?>


in student_edit.php
Code: Select all

<cms:set param1="<cms:gpc 'name' method='get' />" />


<cms:pages masterpage='student/student_edit
.php'  >
    <cms:set my_page_id = "<cms:show param1 />"'global' /> 
</cms:pages>


<cms:form
   class="form-horizontal"
    masterpage='student/student_view.php'      
    mode='edit'
   page_id=my_page_id
    enctype='multipart/form-data'
    method='post'
    anchor='0'
    >

    <cms:if k_success >

        <cms:db_persist_form
            _invalidate_cache='0'
            _auto_title='1'
        />

        <cms:set_flash name='submit_success' value='1' />
        <cms:redirect k_page_link />
    </cms:if>

    <cms:if k_error >
        <div class="error">
            <cms:each k_error >
         <div class="row">
                    <div class="col-md-12">
                          <center><div class="alert alert-warning">
                <br><cms:show item />
            </div></center>
                    </div>
                    </div>   
            </cms:each>
        </div>
    </cms:if>   

form start........

.....
form end....




but one problem is there after click on update button in student_edit.php it updated data but there was a error showing "ERROR: Tag "form" - page_id required"

url-mysite.com/student_edit.php#kformname0

Now I have to just replace this error message with a success message

Thanks

Subhamoy
Ok, please let me know what is the first step with this code:
Code: Select all
<cms:pages masterpage='student/student_edit
.php'  >
    <cms:set my_page_id = "<cms:show param1 />"'global' /> 
</cms:pages>

What would you like to get here? Normally after you recieved submitted name via GET and assigned the value to param1, you can use it within the form:
Code: Select all
<cms:form
   class="form-horizontal"
    masterpage='student/student_view.php'     
    mode='edit'
    page_id=param1

The above will work IF 'name' is an ID, and not the actual student's name. Can you clarify what is 'name' in your setup?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Sir, you are absolutely right.

Code: Select all
<cms:pages masterpage='student/student_edit
.php'  >
    <cms:set my_page_id = "<cms:show param1 />"'global' /> 
</cms:pages>



above code is not making any sense there. Yes I tried before like this
Code: Select all
<cms:form
   class="form-horizontal"
    masterpage='student/student_view.php'     
    mode='edit'
    page_id=param1


but somehow I get a ERROR: Tag "form" - page_id required...
its must be some wrong coded by me in other line. I was overlook then.


Yes, I like to give an input field may be student_name or student_id etc., but I notice that only page Id require in this case. also I thought if I have a list of 500 students then it will be difficult to find a student with link in a page. then I decided print a hard copy details with k_page_id, so editor can collect it from student & find page_id easy, and put it to input field.


It will be better Input Student_Id and then edit. but I have no Idea.
I hope you can now understand what I want to achieve.

Thanks
Subhamoy
5 posts Page 1 of 1