I am using the datetime editable region.
But in the front end I want the date and time to be displayed as a HTML input type date and input type time.
When I use
It works correctly.
But when I use:
It saves the date as:
1970-01-01 00:00
what ever be the date that i fill in. (this only happens when field is not set to required | if set to required it says invalid date).
What can i do? or should i consider a different approach? Please advise.
For what I am trying to use the code is below:
But in the front end I want the date and time to be displayed as a HTML input type date and input type time.
When I use
- Code: Select all
<cms:hide>
<cms:input type="bound" name="input_type_date_time" />
</cms:hide>
<input type="datetime-local" name="f_input_type_date_time" />
It works correctly.
But when I use:
- Code: Select all
<cms:hide>
<cms:input type="bound" name="input_type_date_time" />
</cms:hide>
<input type="date" name="f_input_type_date_time">
<cms:hide>
<cms:input type="bound" name="input_type_date_time" />
</cms:hide>
<input type="time" name="f_input_type_date_time">
It saves the date as:
1970-01-01 00:00
what ever be the date that i fill in. (this only happens when field is not set to required | if set to required it says invalid date).
What can i do? or should i consider a different approach? Please advise.
For what I am trying to use the code is below:
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Date and Time Fields' clonable='1' >
<cms:editable name='input_type_date' label='Input Type = Date' type='datetime' format='Y-m-d' order='1' />
<cms:editable name='input_type_time' label='Input Type = Time' type='datetime' format='H:i' only_time='1' allow_time='1' am_pm='0' order='2' />
<cms:editable name='input_type_date_time' label='Input Type = Date and Time' type='datetime' format='Y-m-d H:i' allow_time='1' am_pm='0' order='3' />
</cms:template>
<!DOCTYPE html>
<html>
<head>
<title>Date and Time Input: CouchCMS</title>
<link rel="stylesheet" type="text/css" href="<cms:show k_site_link />assets/css/gxcpl.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
</head>
<body>
<cms:form
masterpage=k_template_name
mode='create'
enctype='multipart/form-data'
method='post'
anchor='0'
>
<cms:if k_success >
<cms:db_persist_form
_invalidate_cache='0'
_auto_title='1'
/>
<cms:if k_success>
<cms:set_flash name='submit_success' value='1' />
<cms:redirect k_page_link />
</cms:if>
</cms:if>
<table class="gxcpl-table">
<thead>
<tr>
<th width="33%">
Component
</th>
<th width="33%">
HTML
</th>
<th width="34%">
COUCH
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Input <em>type="date"</em>
</td>
<td>
<input type="date" name="" />
</td>
<td>
<cms:hide>
<cms:input type="bound" name="input_type_date" />
</cms:hide>
<input type="date" name="f_input_type_date" />
</td>
</tr>
<tr>
<td>
Input <em>type="time"</em>
</td>
<td>
<input type="time" name="" />
</td>
<td>
<cms:hide>
<cms:input type="bound" name="input_type_time" />
</cms:hide>
<input type="time" name="f_input_type_time" />
</td>
</tr>
<tr>
<td>
Input <em>type="datetime"</em>
</td>
<td>
<input type="datetime-local" name="" />
</td>
<td>
<cms:ignore>
<cms:hide>
<cms:input type="bound" name="input_type_date_time" />
</cms:hide>
<input type="datetime-local" name="f_input_type_date_time" />
</cms:ignore>
<cms:hide>
<cms:input type="bound" name="input_type_date_time" />
</cms:hide>
<input type="date" name="f_input_type_date_time">
<cms:hide>
<cms:input type="bound" name="input_type_date_time" />
</cms:hide>
<input type="time" name="f_input_type_date_time">
</td>
</tr>
</tbody>
<tfooter>
<tr>
<td colspan="3">
<div class="container">
<div class="row">
<div class="col-md-2">
<strong>Alert Message</strong>
</div>
<div class="col-md-10">
<cms:set submit_success="<cms:get_flash 'submit_success' />" />
<cms:if submit_success >
<div class="alert alert-success">
<strong>Success:</strong> Your application has been submitted.
</div>
</cms:if>
<cms:if k_error >
<div class="error">
<cms:each k_error >
<div class="alert alert-danger">
<cms:show item /><br>
</div>
</cms:each>
</div>
</cms:if>
</div>
</div>
</div>
</td>
</tr>
</tfooter>
</table>
<div class="gxcpl-ptop-20"></div>
<div class="container">
<div class="row">
<div class="col-md-12">
<center>
<button class="btn btn-danger btn-sm" type="submit">
SAVE
</button>
</center>
</div>
</div>
</div>
</cms:form>
<div class="gxcpl-ptop-50"></div>
<table class="gxcpl-table" id="ho">
<thead>
<tr>
<th class="text-center" width="10%">
#
</th>
<th width="30%">
Input <em>type=date</em>
</th>
<th width="30%">
Input <em>type=time</em>
</th>
<th width="30%">
Input <em>type=datetime</em>
</th>
</tr>
</thead>
<tbody>
<cms:pages masterapge=k_template_name show_future_entries='1'>
<cms:no_results>
<tr>
<td colspan="4" class="text-center">
- No result -
</td>
</tr>
</cms:no_results>
<tr>
<td class="text-center">
</td>
<td>
<cms:date input_type_date format='Y-m-d' />
</td>
<td>
<cms:date input_type_time format='H:i' />
</td>
<td>
<cms:date input_type_date_time format='Y-m-d H:i' />
</td>
</tr>
</cms:pages>
</tbody>
</table>
<!-- Scripts -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<!-- Scripts -->
</body>
</html>
<?php COUCH::invoke(); ?>