ASD
ASD

Reputation: 4957

How to retain values in yii after submit

Doing a search form in PHP YII in which i need to enter 2 dates field Startdate and enddate, after submitting i will be fetching all the records from table where the contacteddate falls between these start and end date.

The problem is after submitting my textbox values are vanishing. How to retain after submitting?

Upvotes: 2

Views: 1569

Answers (1)

bool.dev
bool.dev

Reputation: 17478

You could use ajax to retrieve the results, instead of the default submit, that way your filter values will not change. The default submit behavior loads(navigates) to a url, hence your values disappear.

You can use CHtml::ajaxSubmitButton() to easily implement this functionality. A sample:

echo CHtml::ajaxSubmitButton(
    'AjaxSearch', // label
    $url,// url that will search
    array('update'=>'#resultdiv'),// the element with id 'resultdiv' will be updated with the search result
    $htmlOptions 
);

Upvotes: 1

Related Questions