Hi all,
I've been having a problem validating a databound form. I was going to post the code for my form, but I decided first to try running the original databound form tutorial (http://docs.couchcms.com/concepts/databound-forms.html). This is the exact code from the tutorial, and it just won't work properly for me.
The problem is that on the front end, there are no errors being recognised, so the success message is displayed. However, the data is not being entered into the template. So I assume that the required and validator tags are being recognised by Couch, but this is not being translated to the front end.
I think this is the first time I have tried using databound forms in this way on 2.0, is this maybe the problem?
Or am I missing something stupid? (this is often the case, just need someone else to look at it and tell me what is wrong!)
I've been having a problem validating a databound form. I was going to post the code for my form, but I decided first to try running the original databound form tutorial (http://docs.couchcms.com/concepts/databound-forms.html). This is the exact code from the tutorial, and it just won't work properly for me.
The problem is that on the front end, there are no errors being recognised, so the success message is displayed. However, the data is not being entered into the template. So I assume that the required and validator tags are being recognised by Couch, but this is not being translated to the front end.
I think this is the first time I have tried using databound forms in this way on 2.0, is this maybe the problem?
Or am I missing something stupid? (this is often the case, just need someone else to look at it and tell me what is wrong!)
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Application Form' clonable='1'>
<cms:editable name='first_name' required='1' type='text' />
<cms:editable name='last_name' required='1' type='text' />
<cms:editable name='email' required='1' validator='email' type='text' />
<cms:editable name='portfolio' validator='url' type='text' />
<cms:editable name='position' required='1' type='dropdown'
opt_values=' Please choose=- | Interface Designer | Software Engineer | Systems Administrator | Office Manager'
/>
<cms:editable name='salary' type='text' search_type='decimal' />
<cms:editable name='resume' required='1' allowed_ext='pdf, doc, docx' max_size='1024' type='securefile' />
</cms:template>
<!doctype html>
<html>
<head>
<title>Employment Application</title>
<style>
body{ width:500px; }
input[type="text"]{ width:99%; }
.error{ color:red; }
</style>
</head>
<body>
<h3>Employment Application</h3>
<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:check_spam email=frm_email />
<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 >
<br><cms:show item />
</cms:each>
</div>
</cms:if>
<label>First Name</label>
<cms:input name="first_name" type="bound" required='1' />
<br />
<label>Last Name</label>
<cms:input name="last_name" type="bound" />
<br />
<label>Email Address</label>
<cms:input name="email" type="bound" />
<br />
<label>Portfolio Website</label>
<cms:input name="portfolio" type="bound" />
<br />
<label>Which position are you applying for? </label>
<cms:input name="position" type="bound" />
<br />
<label>Salary Requirements</label>
<cms:input name="salary" type="bound" />
<br />
<label>Attach a Copy of Your Resume</label>
<cms:input name="resume" type="bound" />
<p>Word or PDF Documents Only</p>
<br />
<label>What colour is a blue apple? (4 characters required)</label>
<cms:input name="human" type="text" required='1' validator='regex=/^blue$/i' />
<br />
<cms:if "<cms:not submit_success />" >
<button type="submit">Submit Application</button>
</cms:if>
</cms:form>
</body>
</html>
<?php COUCH::invoke(); ?>