Hello, guys,
the following code works like a charm inside a view rendered by render(), however, when I use renderPartial(), the same code doesn’t submit the form.
<br/>
<?php echo CHtml::form(’’,‘get’); ?>
Show:
<?php echo CHtml::dropDownList(‘day’,
isset($_GET['showDay'])?(int)$_GET['showDay']:0,
array(1=>'Day 1', 2=>'Day 2'),
array('submit'=>'')); ?>
<?php echo CHtml::endForm(); ?>
<br/>
but, If I change the piece:
array('submit'=>'')); ?>
to
array('onchange'=>'javascript:document.forms[0].submit();')); ?>
it works fine…
To sum up, the ‘submit’ option works in views rendered by render(), but not in views rendered by renderPartial()
:>)
Any idea?
thanks in advance
DARX
(Ioxanssen)
August 22, 2009, 11:53am
2
Hi, scoob!
Let me try to reproduce on my local environment and post results soon here.
UPD:
Variant 1
TestController.php
...
$this->render('_a');
...
views/test/_a.php
<br/>
<?php echo CHtml::form('','get'); ?>
Show:
<?php echo CHtml::dropDownList('day',
isset($_GET['showDay'])?(int)$_GET['showDay']:0,
array(1=>'Day 1', 2=>'Day 2'),
array('submit'=>'')); ?>
<?php echo CHtml::endForm(); ?>
<br/>
it works.
Variant 2
TestController.php
...
$this->render('_a');
...
views/test/_a.php
<?php $this->renderPartial('_b');?>
views/test/_b.php
<br/>
<?php echo CHtml::form('','get'); ?>
Show:
<?php echo CHtml::dropDownList('day',
isset($_GET['showDay'])?(int)$_GET['showDay']:0,
array(1=>'Day 1', 2=>'Day 2'),
array('submit'=>'')); ?>
<?php echo CHtml::endForm(); ?>
<br/>
WOrks fine too…
Hi, scoob!
Let me try to reproduce on my local environment and post results soon here.
UPD:
Variant 1
TestController.php
...
$this->render('_a');
...
views/test/_a.php
<br/>
<?php echo CHtml::form('','get'); ?>
Show:
<?php echo CHtml::dropDownList('day',
isset($_GET['showDay'])?(int)$_GET['showDay']:0,
array(1=>'Day 1', 2=>'Day 2'),
array('submit'=>'')); ?>
<?php echo CHtml::endForm(); ?>
<br/>
it works.
Variant 2
TestController.php
...
$this->render('_a');
...
views/test/_a.php
<?php $this->renderPartial('_b');?>
views/test/_b.php
<br/>
<?php echo CHtml::form('','get'); ?>
Show:
<?php echo CHtml::dropDownList('day',
isset($_GET['showDay'])?(int)$_GET['showDay']:0,
array(1=>'Day 1', 2=>'Day 2'),
array('submit'=>'')); ?>
<?php echo CHtml::endForm(); ?>
<br/>
WOrks fine too…
Thanks, Darmen,
You helped me a lot!!! Now I know the problem is in my code (as usual …hehe)
this is the piece of code that made my submit fail:
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.min.js"></script>
I’m using a js gallery (ad-gallery) to show some photos on this page and it requires this jquery.min.js to work. As Yii has full compatibility with jquery, I thought it wouldn’t cause problems, but it did. Removing this line the submit works, on the other hand, my gallery breaks…so, the only solution I found (no enough time to look for incompatibilities between Yii’s jquery version and jquery.min) was to add the submit manually as in:
array(‘onchange’=>‘javascript:document.forms[0].submit();’)
and keep the <script> line as is because the command
Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.’/js/jquery.min.js’,CClientScript::POS_HEAD);
didn’t work either
the problem was solved
thanks again, Darmen,
regards!!!
:>)