Reputation:
I'm using a datepicker Boostrap in my cakephp application (http://www.eyecon.ro/bootstrap-datepicker/) but, when I try to save the date (to POST) I never get this date by POST.
<?php echo $this->Form->create(false); ?>
<div class="input-append date pull-right" id="dp3" data-date-format="dd-mm-yyyy">
<input class="span2" size="16" type="text" value="Data do Registo" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
(...)
JavaScript:
(function($) {
$(document).ready(function() {
$("#dp3").datepicker()
.on('show', function(ev) {
var today = new Date();
var t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
$('#dp3').data({date: t}).datepicker('update');
});
$('#timepicker1').timepicker();
});
})(jQuery);
Upvotes: 2
Views: 4737
Reputation: 4522
I suppose you're not using the FormHelper to display the date input to include all the classes necessary for datepicker bootstrap. If you have the Security component this will give you problems, but otherwise is ok, I guess... Although I recommend looking up alternatives to integrate both without having to miss the FormHelper -er- help.
But! you're missing the name of the input. FormHelper adds a name to all inputs created by it. So check with firebug or the like what type of name the other input gets. It should be something like this
<div class="input-append date pull-right" id="dp3" data-date-format="dd-mm-yyyy">
<input name="data[FormName][datepicker]" class="span2" size="16" type="text" value="Data do Registo" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
And you'll get it in the action with
$this->request->data['FormName']['datepicker']
Upvotes: 2