Greetings to all!
I am having a slight trouble with a dynamically set dropdown in the Databound Form.
The editable (dynamically populated dropdown) region, even through set to "required=1" allows the DFB to submit; though nothing is submitted to the backend. But, if I do not set the editable region to required, the DBF submits blank to the backend.
My codes are as follows:
Template to create the dropdown values:
Template to fetch the values (defined in the DBF):
I want to be able to stop the DBF from submitting if the dropdowns (session_from and/or session_to) are empty. Please advise.
Regards,
Aashish
I am having a slight trouble with a dynamically set dropdown in the Databound Form.
The editable (dynamically populated dropdown) region, even through set to "required=1" allows the DFB to submit; though nothing is submitted to the backend. But, if I do not set the editable region to required, the DBF submits blank to the backend.
My codes are as follows:
Template to create the dropdown values:
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='SA - Add Academic Year' parent='_sas_' hidden='0' clonable='1' order='1' />
<?php COUCH::invoke(); ?>
Template to fetch the values (defined in the DBF):
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Academic Session - Settings' parent='_session_' clonable='1' order='1'>
<cms:editable name='session_from' label='Session From (YYYY)' type='text' />
<cms:editable name='session_to' label='Session To (YYYY)' type='text' />
</cms:template>
<!Doctype html>
<html>
<head>
<title>
Set Academic Session
</title>
<link rel="stylesheet" href="<cms:show k_site_link />assets/css/bootstrap.css">
<link rel="stylesheet" href="<cms:show k_site_link />assets/css/font-awesome.css">
<link rel="stylesheet" href="<cms:show k_site_link />assets/css/gxcpl.css">
</head>
<body>
<div class="gxcpl-ptop-50"></div>
<div class="gxcpl-ptop-10"></div>
<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' >
<!-- Success Block -->
<cms:if k_success >
<cms:db_persist_form
_invalidate_cache='0'
k_page_title="Academic Session - <cms:show frm_session_from /> to <cms:show frm_session_to />"
k_page_name="<cms:random_name />"
/>
<cms:set_flash name='submit_success' value='1' />
<cms:redirect k_page_link />
</cms:if>
<!-- Success Block -->
<!-- Error Block -->
<cms:if k_error >
<div class="container">
<div class="row">
<cms:each k_error >
<div class="col-md-4" style="height: 60px;">
<div class="alert alert-danger" role="alert">
<small><cms:show item /></small>
</div>
<div class="ptop-10"></div>
</div>
</cms:each>
</div>
<div class="ptop-20"></div>
</div>
</cms:if>
<!-- Error Block -->
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h3 class="gxcpl-no-margin">Set Current Academic Year</h3>
<div class="gxcpl-ptop-20"></div>
</div>
<div class="col-md-12">
<label>From</label>
<br />
<cms:hide><cms:input name="session_from" type="bound" /></cms:hide>
<select name="f_session_from" class="form-control">
<option selected disabled>Select academic session start year</option>
<cms:pages masterpage="add-session-year.php" order="asc">
<option><cms:show k_page_title /></option>
</cms:pages>
</select>
<div class="gxcpl-ptop-20"></div>
</div>
<div class="col-md-12">
<label>To</label>
<br />
<cms:hide><cms:input name="session_to" type="bound" /></cms:hide>
<select name="f_session_to" class="form-control">
<option selected disabled>Select academic session end year</option>
<cms:pages masterpage="add-session-year.php" order="asc">
<option><cms:show k_page_title /></option>
</cms:pages>
</select>
<div class="gxcpl-ptop-20"></div>
</div>
<div class="col-md-2">
<button class="btn btn-primary" style="font-weight: bold;" type="submit"><i class="fa fa-save"></i> SAVE</button>
</div>
</div>
</div>
</cms:form>
<script src="<cms:show k_site_link />assets/js/jquery-2.1.0.js"></script>
<script src="<cms:show k_site_link />assets/js/bootstrap.js"></script>
</body>
</html>
<?php COUCH::invoke(); ?>
I want to be able to stop the DBF from submitting if the dropdowns (session_from and/or session_to) are empty. Please advise.
Regards,
Aashish