Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Well, let me start with the error:

image_file: Required field cannot be left empty


This error is given whether the field is filled or not. When I removed the requirement from the field, the image was not uploaded.

Relevant code pt 1: The Form

Code: Select all
<div class='panel panel-primary'>
                           <div class='panel-heading'>
                              <h2>Upload a New Image</h2>
                           </div>
                           <div class='panel-body' >

                              <cms:form masterpage='relation_gallery.php' mode='create' method='post' role='form' anchor='0'>

                                 <cms:if k_success >
                                    <cms:db_persist_form
                                       _invalidate_cache='0'
                                    />           
                                    <h4 id='successMessage' class='alert alert-success'>Your image has uploaded!</h4>
                                    <script>
                                       setTimeout(function() {
                                          $('#successMessage').fadeOut('slow',function() {
                                             $(this).alert('close');
                                          })
                                       }, 2500);
                                    </script>
                                 </cms:if>

                                 <cms:if k_error >
                                    <div class="error alert alert-danger">
                                       <a class="close" data-dismiss="alert" href="#" aria-hidden="true">&times;</a>
                                       <cms:each k_error >
                                          <br><cms:show item />
                                       </cms:each>
                                    </div>
                                 </cms:if>   
                                 <div class='form-group'>
                                    <div class='row'>
                                       <div class='col-md-8'>
                                          <label>Image Title</label><br/>
                                          <cms:input class='form-control' type='bound' name='k_page_title' />
                                       </div>
                                       <div class='col-md-4'>
                                          <label>Image Type</label><br/>
                                          <cms:input class='form-control' type='bound' name='gallery_name' />
                                       </div>
                                    </div><br/>
                                    <div class='row'>
                                       <div class='col-md-6'>
                                          <label>Image Upload</label><br/>
                                          <cms:input type='bound' name='image_file' />
                                       </div>
                                       
                                    </div><hr/>
                                    <div class='row'>
                                       <div class='col-md-3'>
                                          <button role='submit' class='btn btn-primary'>Submit</button>&nbsp;<button role='button' onclick='window.history.back()' class='btn btn-default'>Cancel</button>
                                       </div>
                                    </div>
                                    
                                 </div>
                              </cms:form>
                           </div>   
                        </div>


Relevant code pt 2, the source template:

Code: Select all
<?php require_once ($_SERVER["DOCUMENT_ROOT"] . "/couch/cms.php" ); ?><cms:template name='relation_gallery' title="New Gallery" hidden='1' clonable='1' routable='1'>
   <cms:editable type='dropdown' required='1' name='gallery_name' label='Gallery Name' opt_values="**Please Select**=- | Childrens=child | Young Adult=ya | Columbia County=cco | Euchee Creek=ec | Harlem=har | Burke County=bco | Sardis=sar | Midville=mid | Lincoln County=lco | Warren County=wco | Systems=sysmsg" />
   <cms:editable type='securefile' name='image_file' allowed_ext='png, jpg, jpeg, gif' max_size='8192' width='800' height='600' thumb_height='80' show_preview='1' use_thumb_for_preview='1' required='1' />
</cms:template>
<?php COUCH::invoke(); ?>


Possibly Relevant Info:

I've got the form within a routable template. No errors are being thrown, however, and I have several other forms within routable templates that work without error.

The template containing the form is not within the root folder; but, again, neither are several other forms that are working correctly.
Hi,

Please try adding the highlighted param to cms:form:
<cms:form masterpage='relation_gallery.php' mode='create' method='post' enctype='multipart/form-data' role='form' anchor='0'>

Hope it helps.
That's what I get for reusing code without double-checking it!

Thanks, KK.
3 posts Page 1 of 1