I am rendering form elements in a sidebar, but I want these elements submitted along with other form elements in the page. Because of the way the page is rendered it is not possible to put form tags above and below all form elements without actually nesting form tags in the layout rather than the view.
//Outputs form tag as expected
<?php echo CHtml::beginForm('','get'); ?>
//Outputs select element as expected within the form
<?php echo CHtml::activeLabel($model, "cohort");?>
<?php echo CHtml::activeDropDownList($model, "cohort", Yii::app()->common->cohortsDropDown,array(
'id'=>'cohort-external-filter',
'class'=>'span2',
'prompt'=>'',
));?>
<?php// This passes the output of the renderPartial to $this->filterForm which is rendered in the layout (sidebar)
$this->filterForm =$this->renderPartial('/_forms/ks4FilterForm',array(
'model'=>$model,
'form'=>$form),true
);?>
<?php//Rendered as expected within the form
$this->widget('bootstrap.widgets.BootGridView',array(
'id'=>'ks4summary-grid1',
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'name'=>'col1',
'header'=>'',
//'htmlOptions'=>array('width'=>'80px'),
),
array(
'name'=>'col2',
'header'=>'Total',
//'htmlOptions'=>array('width'=>'80px'),
),
),
)); ?>
//Outputs the end form tag above the rendered form held in $this->filterForm which is useless
<?php echo CHtml::endForm()?>
I know why this is happening, but starting to embed form tags within layouts e.g. in column1_with_form_tags just feels wrong. Is there another/proper way of dealing with this without writing a load of jquery.
Many thanks