Note that there are some explanatory texts on larger screens.

plurals
  1. POcakephp - datepicker bootstrap not populate when use a edit action
    primarykey
    data
    text
    <p>I'm using a datepicker for bootstrap in my application. Here is my HTML code:</p> <pre><code>&lt;div class="input-append date pull-right" id="dp3" data-date-format="dd-mm-yyyy"&gt; &lt;input name="dataregisto" id="dataregisto" class="span2" size="16" type="text" readonly&gt; &lt;span class="add-on"&gt;&lt;i class="icon-th"&gt;&lt;/i&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>So when I save the data, it works normally, but when I edit a record the date doesn't show. On the other hand, all remaining data are populated. My JavaScript code:</p> <pre><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); </code></pre> <p>CONTROLLER</p> <pre><code> function edit($id = null) { session_start(); if (isset($_SESSION['username'])) { /* verifica se existe uma sessão */ $this-&gt;Registo-&gt;id = $id; if (empty($this-&gt;data)) { /* acede aos projetos */ $this-&gt;set('projects', $this-&gt;Registo-&gt;Project-&gt;find('list', array('fields' =&gt; array('pname')))); /* acede ás versoes do projecto a editar */ $this-&gt;set('projectversions', $this-&gt;requestAction("/ProjectVersions/getversionsofproject", array('projects' =&gt; $this-&gt;Registo-&gt;read()['Registo']['projects']))); /* acede aos clientes */ $this-&gt;set('clients', $this-&gt;requestAction("/CustomFieldOptions/getClients")); /* acede ás issuetypes */ // $issuetype= $this-&gt;requestAction("/Projects/getissuetypeofproject", array('projects' =&gt; $this-&gt;Registo-&gt;read()['Registo']['projects'])); $this-&gt;set('dataregisto', $this-&gt;Registo-&gt;read()['Registo']['dataregisto']); /* $issuetype = array(); foreach($IssueTypes as $value) { $value = $value['IssueType']['id']; $issuetype[$value['IssueType']['id']] = $value['IssueType']['pname']; } debug($issuetype); */ $this-&gt;set('issuetype', $issuetype); $this-&gt;request-&gt;data = $this-&gt;Registo-&gt;read(); } else { if ($this-&gt;Registo-&gt;save($this-&gt;request-&gt;data)) { $this-&gt;Session-&gt;setFlash(__('Registo alterado com sucesso', true), 'flash_success'); $this-&gt;redirect(array('action' =&gt; 'index')); } else { $errors = $this-&gt;Registo-&gt;invalidFields(); $this-&gt;Messages-&gt;customize_error_msg($errors['issuetype']); } } } else { $this-&gt;redirect(array('controller' =&gt; 'users', 'action' =&gt; 'login')); // $this-&gt;Session-&gt;setFlash(__('Por favor efetue LOGIN para poder aceder a esta página!', true), 'flash_success'); } } </code></pre> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload