Forum for discussing general topics related to Couch.
30 posts Page 3 of 3
Hi,

I am getting the ID when im using

<cms:set edit_user = "<cms:gpc method='get' var='id'/>" 'global'/>

But when i click the SAVE button i get the ERROR.

ERROR: Tag "form" - page_id required
Please post your user-admin-edit.php file here (inside of
Code: Select all
...paste here
tags) for me to see if anything is wrong with your code.
Image
Bartonsweb wrote: Please post your user-admin-edit.php file here (inside of
Code: Select all
<?php require_once( '../admin/cms.php' ); include 'header.php'; ?>
    <cms:template title='Cours Edit' hidden='0' order='13' access_level='10' />
    <cms:set edit_user = "<cms:gpc method='get' var='id'/>" 'global'/>
    <!-- this is secured page. login first to access it -->
    <cms:if k_logged_out >
        <cms:redirect "<cms:login_link />" />
    </cms:if>


    <div class="container body">


        <div class="main_container">

            <div class="col-md-3 left_col">
               
<?php include ('menu.php'); ?>               

            <!-- page content -->
            <div class="right_col" role="main">
                <div class="">



                    <div class="row">

                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <div class="x_panel">
                                <div class="x_title">
                                    <h2>Rediger opplysninger vedrørende kurs </h2>
                                        <cms:set success_msg="<cms:get_flash 'success_msg' />" />
                                        <cms:if success_msg >
                                        <h2> - Endringer ble lagret velykket!</h2>
                                        </cms:if>
                                    <ul class="nav navbar-right panel_toolbox">
                                        <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                        </li>
                                        <li class="dropdown">
                                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                            <ul class="dropdown-menu" role="menu">
                                                <li><a href="#">Settings 1</a>
                                                </li>
                                                <li><a href="#">Settings 2</a>
                                                </li>
                                            </ul>
                                        </li>
                                        <li><a class="close-link"><i class="fa fa-close"></i></a>
                                        </li>
                                    </ul>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="x_content">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                                <th style='width:100px;'>Ansatt ID</th>
                                                <th>Navn</th>

                                            </tr>
                                        </thead>
                                                                               
                                        <cms:form                                                   
                                            masterpage=k_user_template
                                            mode='edit'
                                            page_id=edit_user
                                            nctype="multipart/form-data"
                                            method='post'
                                            anchor='0'
                                        >
       
                                        <cms:if k_success >
                                            <cms:db_persist_form />

                                            <cms:if k_success >
                                                <cms:set_flash name='success_msg' value='1' />
                                                <cms:redirect k_page_link />
                                            </cms:if>
                                        </cms:if> 
       
                                        <cms:if k_error >
                                            <font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
                                        </cms:if>
                                                   
                                        <tbody>
                                            <tr><cms:show edit_user/>
                                                <th scope="row"><cms:input name='employee_id' type='bound' class="form-control col-md-2 col-xs-12"/></th>
                                                <td><cms:input name='fullname' type='bound' class="form-control col-md-10 col-xs-12"/></td>         
                                            </tr>                                         
                                        </tbody>
                                        <thead>
                                            <tr>
                                                <th>Anhuker</th>
                                                <th>Dokument</th>
                                                <th>Utløper</th>
                                            </tr>
                                        </thead>       
                                        <tbody>
                                            <tr>                                           
                                                <td><cms:input name='varmearbeider' type='bound' /></td>
                                                <td><cms:input name='varmearbeider_doc' type='bound' class="form-control col-md-10 col-xs-12"/></td>
                                                <td><cms:input name='end_date_1' type='bound' class="date-picker form-control col-md-7 col-xs-12"/></td>                                                           
                                            </tr>
                                        </tbody>       
                                        <thead>
                                            <tr>
                                                <th>Anhuker</th>
                                                <th>Dokument</th>
                                                <th>Utløper</th>
                                            </tr>
                                        </thead>       
                                        <tbody>
                                            <tr>                                           
                                                <td><cms:input name='anhuker' type='bound' /></td>
                                                <td><cms:input name='anhuker_doc' type='bound' class="dropzone"/></td>
                                                <td><cms:input name='end_date_2' type='bound' class="date-picker form-control col-md-7 col-xs-12"/></td>                                                             
                                            </tr>
                                        </tbody>
                                        <thead>
                                            <tr>
                                                <th>Arbeid i høyde</th>
                                                <th>Dokument</th>
                                                <th>Utløper</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>                                           
                                                <td><cms:input name='arbeid_hoyt' type='bound' /></td>
                                                <td><cms:input name='arbeid_hoyt_doc' type='bound' class="form-control col-md-10 col-xs-12"/></td>
                                                <td><cms:input name='end_date_3' type='bound' class="date-picker form-control col-md-7 col-xs-12"/></td>                                                               
                                            </tr>
                                        </tbody>       
                                   
                                    </table>
                                   
                                    <input type="submit" name="submit" value="Save" class="btn btn-primary" />   
   
                                        </cms:form>
                                   
                                </div>
                            </div>
                        </div>                   

                        <div class="clearfix"></div>

                    </div>

                </div>

            </div>
            <!-- /page content -->
        </div>

    </div>

    <div id="custom_notifications" class="custom-notifications dsp_none">
        <ul class="list-unstyled notifications clearfix" data-tabbed_notifications="notif-group">
        </ul>
        <div class="clearfix"></div>
        <div id="notif-group" class="tabbed_notifications"></div>
    </div>

    <script src="js/bootstrap.min.js"></script>
   
    <script src="js/nicescroll/jquery.nicescroll.min.js"></script>
    <!-- icheck -->
    <script src="js/icheck/icheck.min.js"></script>

    <script src="js/custom.js"></script>

</body>

</html>   

<?php COUCH::invoke(); ?>
tags) for me to see if anything is wrong with your code.
Is the user ID correct from your <cms:show edit_user /> ?

Edit: can you do a <cms:dump /> and tell me if the "edit_user" variable is in it?
Image
Bartonsweb wrote: Is the user ID correct from your <cms:show edit_user /> ?

Edit: can you do a <cms:dump /> and tell me if the "edit_user" variable is in it?


__ROOT__
k_user_id: 12
k_user_name: heggenes
k_user_title: heggenes
k_user_email: heggenes@hotmail.com
k_user_access_level: 10
k_user_disabled: 0
k_logged_in: 1
k_logout_link: http://www.boas.as/test/users/login.php ... %3Fid%3D12
k_extended_user_id: 1
k_user_template: users/index.php
k_user_login_template: users/login.php
k_user_lost_password_template: users/register.php
k_user_registration_template: users/lost-password.php
k_cms_version: 1.4.7
k_cms_build: 20151124
k_admin_link: http://www.boas.as/test/admin/
k_admin_page:
k_site_link: http://www.boas.as/test/
k_admin_path: /home/2/b/boas/www/test/admin/
k_site_path: /home/2/b/boas/www/test/
k_template_title: Cours Edit
k_template_name: users/users-cours-admin-edit.php
k_template_id: 17
k_template_is_clonable: 0
k_template_desc:
k_template_access_level: 10
k_template_is_commentable: 0
k_template_is_executable: 1
k_template_is_hidden: 0
k_template_order: 13
k_template_nested_pages: 0
k_template_gallery: 0
k_template_link: http://www.boas.as/test/users/users-cou ... n-edit.php
k_prettyurls: 0
k_site_charset: iso-8859-1
k_email_from: noreply@boas.no
k_email_to: noreply@boas.no
k_is_commentable: 0
k_is_list_page: 1
k_is_list: 0
k_is_page: 0
k_comments_count: 0
k_access_level: 0
k_page_date: 2016-02-15 01:02:57
k_page_creation_date: 2016-02-15 01:02:57
k_page_modification_date: 0000-00-00 00:00:00
k_page_draft_of: 0
k_page_id: 19
k_page_link: http://www.boas.as/test/users/users-cou ... n-edit.php
edit_user: 12
Are you sure that the user_id=edit_user line doesn't need to go inside the <cms:db_persist_form /> tag? Like so;

Code: Select all
<cms:db_persist_form user_id=edit_user />


Rather than on the form tag (it does noting on there afaik - I should've spotted this earlier, my apologies)

Hopefully this works, if not I will have to look into data bound forms again - it's been a while
Image
Thanks for entrusting me with FTP + Couch credentials for your site.

Though, I shouldn't have needed them if I had used my eyes correctly.

There was just a simple typo in the form:

Code: Select all
                                        <cms:form                                                   
                                            masterpage=k_user_template
                                            mode='edit' 
                                            page_id=edit_user 
                                            nctype="multipart/form-data"
                                            method='post'
                                            anchor='0'
                                        >

became:

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


Now it loads the page correctly, sorry for the delay in fixing the issue - I need new glasses!
Image
Bartonsweb wrote: Thanks for entrusting me with FTP + Couch credentials for your site.

Though, I shouldn't have needed them if I had used my eyes correctly.

There was just a simple typo in the form:

Code: Select all
                                        <cms:form                                                   
                                            masterpage=k_user_template
                                            mode='edit' 
                                            page_id=edit_user 
                                            nctype="multipart/form-data"
                                            method='post'
                                            anchor='0'
                                        >

became:

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


Now it loads the page correctly, sorry for the delay in fixing the issue - I need new glasses!


Ah...I did now put the 'e' to nctype but the page still now working. Or maybe im doing something wrong!
Okay, I've fixed the entire issue now.

It seems there were 2 more errors on the page: Firstly, the wrapping of elements in the template was messy, this meant the form was broken upon output:
this is what your code looked like (cleaned up so you can see)
Code: Select all
<table>
   <thead>...</thead>
   <cms:form>
   <tbody>...</tbody>
</table>
<cms:input type='submit'>
</cms:form>

So the table ended before the form, this meant in the output the form would close itself instantly, so none of the inputs were properly tied to it.
The fixed version was to just move the <cms:form> opener outside of the <table> so the entire table is inside the form.

The next issue was the bigger one and I only fixed this by checking the couch documentation on databound forms (I didn't actually know this was an issue until I tested it):

You were using
Code: Select all
<cms:input type='submit' name='submit value='Save' />

for your form submission button. Pressing this button caused the error you had.

The couch documentation on databound forms (See: http://docs.couchcms.com/concepts/databound-forms.html) uses
Code: Select all
 <button type="submit">Submit Application</button>

to submit its forms.
Once I changed your input to a button, the form correctly works.

So there were a bunch of different errors all causing this to not work as correctly. Hopefully they're all resolved now, I was unaware of the need for a <button> over an input for databound forms, I guess we learn more every day :)

I hope it's all working as desired now Kimheggen.
Image
Bartonsweb wrote: Okay, I've fixed the entire issue now.

It seems there were 2 more errors on the page: Firstly, the wrapping of elements in the template was messy, this meant the form was broken upon output:
this is what your code looked like (cleaned up so you can see)
Code: Select all
<table>
   <thead>...</thead>
   <cms:form>
   <tbody>...</tbody>
</table>
<cms:input type='submit'>
</cms:form>

So the table ended before the form, this meant in the output the form would close itself instantly, so none of the inputs were properly tied to it.
The fixed version was to just move the <cms:form> opener outside of the <table> so the entire table is inside the form.

The next issue was the bigger one and I only fixed this by checking the couch documentation on databound forms (I didn't actually know this was an issue until I tested it):

You were using
Code: Select all
<cms:input type='submit' name='submit value='Save' />

for your form submission button. Pressing this button caused the error you had.

The couch documentation on databound forms (See: http://docs.couchcms.com/concepts/databound-forms.html) uses
Code: Select all
 <button type="submit">Submit Application</button>

to submit its forms.
Once I changed your input to a button, the form correctly works.

So there were a bunch of different errors all causing this to not work as correctly. Hopefully they're all resolved now, I was unaware of the need for a <button> over an input for databound forms, I guess we learn more every day :)

I hope it's all working as desired now Kimheggen.


I must say...GREAT WORK and THANKS ALOT.

Tested it now and it works like a sharm :) A big step forward for me :)

Yes you said it, we all learn something everyday :)
30 posts Page 3 of 3