Hi, In cakephp I cant set the selected option on a dropdown list when i
post.
Wjat happens is that I select an option and Post. Then the controller will
find the data and go back to the same page but the selected value in the
selected list is the the default.
So I should select a date from the list, press button and be redirected to
the same page with the selected date. That date should be selected in the
select list. The code works but the selected option doesnt stay the same
when the page is redirected back to the same page from the controller.
//controller
if (isset($this->request->data['button1'])) {
$startdate=$this->request->data['Lesson']['ChooseAPaycycleStartDate'];
$enddate=date('Y-m-d',strtotime ( +13 . ' day' , strtotime
( $startdate)));
$this->redirect(array('action' =>
'lesson_plan',$startdate,$enddate));
}
/////view
echo $this->Form->create();
echo $this->Form->input('ChooseAPaycycleStartDate',
array('options' =>
array('2014-10-06'=>'06-10-2014' ,
'2014-10-20'=>'20-10-2014', '2014-11-3'=>'3-11-2014',
'2014-01-01'=>'01-01-2014')));
// , 'type' => 'select', 'selected' => 2)));
echo $this->Form->submit('Get Lesson
Plans',array('name'=>'button1'));
echo $this->Form->end();
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.