cakephp 2.3 format time input hours minutes seconds -
i'm trying format input without success. need save mp3 table duration of each audio file. that, have input allows me choose hours:minutes:seconds. field duration in table time, don't need datetime guess.
so here i've done doesn't work:
<?php echo $this->form->input('duration', array('type' => 'time', 'label' => 'durée piste', 'dateformat' => 'h:i:s')); ?>
does knows how that? in advance!
if not php expert can go simple code given below.
note: post model name.so replace yours.
add function in controller
public function add() { if ($this->request->is('post')) { $this->post->create(); $hours = $this->data['post']['hours']; $minutes = $this->data['post']['minutes']; $seconds = $this->data['post']['seconds']; $this->request->data['post']['duration']=$hours.':'.$minutes.':'.$seconds; if ($this->post->save($this->request->data)) { $this->session->setflash('your post has been saved.'); $this->redirect(array('action' => 'index')); } else { $this->session->setflash('unable add post.'); } } }
code in add.ctp file
$hours=array(); for($i=0;$i<13;$i++){ $hours[$i]=$i; } $ms=array(); for($i=0;$i<60;$i++){ $ms[$i]=$i; } echo $this->form->input('hours',array('type' => 'select', 'options' => $hours)); echo $this->form->input('minutes',array('type' => 'select', 'options' => $ms)); echo $this->form->input('seconds',array('type' => 'select', 'options' => $ms));
Comments
Post a Comment