Hi, banging my head on the wall on this one. I’m trying to update my gridviewer(for a message board) according to different dates on the click of a button.
for example in my view :
{input date} {Button} {ajax Button}
<div id="data">
{[Gridview according to dates]}
</div>
then everytime i click the {button} or {ajax Button} the gridviewer should filter only messages for the dates according to {input date}. My problem now is my action doesn’t see the variable ($data) passed by either CHtml:Button, or CHtml:AjaxButton.
my Button code in my view file:
<div class="form">
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array( // using datepicker to get input date
'model' => $model,
'attribute' => 'start_date',
.....
));
$data["myDate"] = $model->start_date;
var_dump($data);
echo CHtml::button('Click me', array('submit' => array('message/viewMessageBoardByDate', array('data'=>$data))));
echo CHtml::ajaxButton(
'Index submit button',
array('message/viewMessageBoardByDate'), //controller
array('update'=>'#data')
);
the var_dump($data) gives "array(1) { ["myDate"]=> NULL }".
if i change my button to :
echo CHtml::button('Click me', array('submit' => array('message/viewMessageBoardByDate','data'=>$data)));
Also the same.
now in my Message controller :
public function actionViewMessageBoardByDate()
{
var_dump($data);
$this->renderPartial('/message/viewMessageBoardOnly',array('data'=>$data));
}
Right now clicking the {button} shows Undefined variable: data . clicking the {ajax Button} gives no response at all, not even error…
In my view file i have a CGridView widget to show the messages according to the input date.(should be no problem with that. Ok when i tested it separately)
Am i passing the variables wrong? is there a special way to do it using buttons? Both buttons and datepicker are inside a form. I do have a <div> with id ‘data’ for the ajaxbutton to update the content. This post seems to do it ok.
Any idea on how to troubleshoot ? or is there a better way to do the function?
Thanks in advance.
[EDIT]
Just realized that variables passed this way are accessed using the $_GET[’’]… var_dump($_GET[‘data’]) gives " array(1) { [“myDate”]=> string(0) “” } ". How do i make it as the input i get from DatePicker?