cnick79
(Cnick79)
August 5, 2012, 8:58pm
1
I have an active form widget and when somebody clicks on a button in the form I want to display the data from a partial view, and if it’s already shown, then I want to hide it/remove it.
When the form get’s submitted, I only care about the fields that are shown and filled in from the partial view.
view.php
<?php echo CHtml::ajaxButton('Box1', $this->createUrl('box1'), array('update' => '#box1')); ?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'box-form',
'enableAjaxValidation'=>false,
)); ?>
<div id="box1">
</div>
<div id="box2">
</div>
<?php $this->endWidget(); ?>
</div><!-- end form -->
controller.php
public function actionBox1() {
$this->renderPartial('_box1');
}
_box1.php (_box2 would be the same/similar)
<h3>Box1</h3>
<div class="row">
<?php echo $form->labelEx($model,'box_message'); ?>
<?php echo $form->textArea($model,'box_message'); ?>
<?php echo $form->error($model,'box_message'); ?>
</div>
beesho
(Bg 11)
November 14, 2012, 5:37pm
2
cnick79:
I have an active form widget and when somebody clicks on a button in the form I want to display the data from a partial view, and if it’s already shown, then I want to hide it/remove it.
When the form get’s submitted, I only care about the fields that are shown and filled in from the partial view.
view.php
<?php echo CHtml::ajaxButton('Box1', $this->createUrl('box1'), array('update' => '#box1')); ?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'box-form',
'enableAjaxValidation'=>false,
)); ?>
<div id="box1">
</div>
<div id="box2">
</div>
<?php $this->endWidget(); ?>
</div><!-- end form -->
controller.php
public function actionBox1() {
$this->renderPartial('_box1');
}
_box1.php (_box2 would be the same/similar)
<h3>Box1</h3>
<div class="row">
<?php echo $form->labelEx($model,'box_message'); ?>
<?php echo $form->textArea($model,'box_message'); ?>
<?php echo $form->error($model,'box_message'); ?>
</div>
@cnick79 ,
Did you manage to solve that?
I am trying to do just the same thing but with no luck…
Can you plz explain the basics of solving this?
Any help is appreciated!