Hi all,
I am running into issues getting a POST-based form used to provide filter/sesarch conditions with a Gridview with column sorting capabilities.
I have it working if the form is set for GET - pagination, sort, and filter - however in doing so, the URL becomes bulky and unreadable, along with the fact I’d like to hide the search query string from the user where possible (and what happens if it exceeds maximum length of url?).
In 1.1.14 there is a new var called ajaxType which I have tried setting to POST however this does not resolve the problem.
I guess I could separate the controller actions and give it a dedicated ajaxUrl and come up with some means for passing filter information between controller methods however I feel this is a non-intuitive and possibly dirty workaround.
I have spent the last week or so trying to dig through this however I have had no resolve. The column headers are still GET based ajax links, and clicking them in a POST-based form causes a loss of filter.
Any help, suggestions or hints as to where to look would be greatly appreciated!
Here is some code snippets which illustrate my setup:
Controller:
function actionAdvSearch() {
$model = new Post('search');
$model->Author = new Author('search');
$model->unsetAttributes();
if (isset($_POST['Post'])) {
$model->attributes = $_POST['Post'];
}
$this->render('advsearch', array('model' => $model));
}
View: /post/advSearch/
<?php $form = $this->beginWidget('CActiveForm', array(
'id'=>'post-form',
'method' => 'post'
)); ?>
<div class="row-fluid">
<div class="span4">
<?php echo $form->label($model, 'id'); ?>
</div>
<div class="span8">
<?php echo $form->textField($model, 'id', array('maxlength' => 45)); ?>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<?php echo $form->label($model->author, 'name'); ?>
</div>
<div class="span8">
<?php echo $form->textField($model->author, 'name', array('maxlength' => 80)); ?>
</div>
</div>
<div class="row-fluid">
<?php echo CHtml::submitButton(); ?>
</div>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'ajaxType' => 'post',
'type' => 'condensed bordered striped',
'columns' => $columns,
'dataProvider' => $model->search(),
));
?>
<?php $this->endWidget(); ?>