php - cakephp - datepicker bootstrap not populate when use a edit action -


i'm using datepicker bootstrap in application. here html code:

<div class="input-append date pull-right" id="dp3" data-date-format="dd-mm-yyyy">    <input name="dataregisto" id="dataregisto" class="span2" size="16" type="text" readonly>    <span class="add-on"><i class="icon-th"></i></span> </div>  

so when save data, works normally, when edit record date doesn't show. on other hand, remaining data populated. javascript code:

(function($) {     $(document).ready(function() {         var today = new date();         var t = today.getdate() + "-" + (today.getmonth() + 1) + "-" + today.getfullyear();         $("#dp3").datepicker()                 .on('show', function(ev) {              $('#dp3').data({date: t}).datepicker('update');         });           //    $('#timepicker1').timepicker();           document.getelementbyid("dataregisto").value = document.getelementbyid("dataregisto").defaultvalue = t;     });  })(jquery); 

controller

 function edit($id = null) {      session_start();     if (isset($_session['username'])) { /* verifica se existe uma sessão */         $this->registo->id = $id;         if (empty($this->data)) {             /* acede aos projetos */             $this->set('projects', $this->registo->project->find('list', array('fields' => array('pname'))));             /* acede ás versoes projecto editar */             $this->set('projectversions', $this->requestaction("/projectversions/getversionsofproject", array('projects' => $this->registo->read()['registo']['projects'])));             /* acede aos clientes */             $this->set('clients', $this->requestaction("/customfieldoptions/getclients"));             /* acede ás issuetypes */             // $issuetype= $this->requestaction("/projects/getissuetypeofproject", array('projects' => $this->registo->read()['registo']['projects']));              $this->set('dataregisto', $this->registo->read()['registo']['dataregisto']);             /*  $issuetype = array();                foreach($issuetypes $value) {               $value = $value['issuetype']['id'];               $issuetype[$value['issuetype']['id']] = $value['issuetype']['pname'];               }                 debug($issuetype); */              $this->set('issuetype', $issuetype);             $this->request->data = $this->registo->read();         } else {             if ($this->registo->save($this->request->data)) {                 $this->session->setflash(__('registo alterado com sucesso', true), 'flash_success');                 $this->redirect(array('action' => 'index'));             } else {                 $errors = $this->registo->invalidfields();                 $this->messages->customize_error_msg($errors['issuetype']);             }         }     } else {         $this->redirect(array('controller' => 'users', 'action' => 'login'));         // $this->session->setflash(__('por favor efetue login para poder aceder esta página!', true), 'flash_success');     } } 

thank you!

are sure, save inserted data, eg. in mysql database in dd-mm-yyyy format? solution or detected bug.

edit: take documentation

(function($) {     $(document).ready(function() {         var today = new date(), t = today.getdate() + "-" + (today.getmonth() + 1) + "-" + today.getfullyear();         $("#dp3").datepicker().on('show', function(e) {             e.preventdefault();             $(this).datepicker('setvalue', t);         });         document.getelementbyid("dataregisto").value = document.getelementbyid("dataregisto").defaultvalue = t;     }); })(jquery); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -