Need Help,
Is there any possibility one click save to all tabs in CjuiTabs ?
these are my model
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs' => array(
'Form1' => $this->renderPartial('_form1',array('model' => $model),true),
'Form2' => $this->renderPartial('_form2',array('model' => $model),true),
),
'options' => array(
'collapsible' => true,
),
));
current view in _form1.php and _form2.php i have to add submit button in CActiveForm
..
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
...
Is there Any one save Click to all tabs? how do i do that?
zaccaria
(Matteo Falsitta)
September 27, 2010, 10:39am
2
When you click save, the whole data from all tabs will be submitted, isn’t it?
You should just collect all of them and save.
zaccaria:
When you click save, the whole data from all tabs will be submitted, isn’t it?
You should just collect all of them and save.
Hello Zaccaria,
thanks for your fast replay…
Yes its strange,I make form from CRUD Wizard.
in my model
TableA
id fieldA FieldB
1 AAA1 BBB1
2 AAA2 BBB2
in my form.php
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs' => array(
'Form1' => $this->renderPartial('_form1',array('model' => $model),true),
'Form2' => $this->renderPartial('_form2',array('model' => $model),true),
),
));
in my _form1.php
..
<?php echo $form->textField($model,'fieldA'); ?>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
..
in my _form2.php
..
<?php echo $form->textField($model,'fieldB'); ?>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
..
there was 2 submit button in 2 tabs ( each tab have 1 submit button)
if i edit Field A and save in tab 2(_form2.php) it wont save…
can you help me?
zaccaria
(Matteo Falsitta)
September 28, 2010, 6:11am
4
It’s because you created 2 form, so you will have only the data of the form you submit
Try like that:
in form.php:
$form->beginForm();
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs' => array(
'Form1' => $this->renderPartial('_form1',array('model' => $model),true),
'Form2' => $this->renderPartial('_form2',array('model' => $model),true),
),
));
$form->endForm();
And in the view _form1 and _form2 don’t open/close form.
This should submit all data of both form.
You may also place only one submit button under the cjuitabs, so it will be more intuitive that this button is submitting all (is just design, no difference at all in logic)
wow … Its simple 'est solution that i had found…
Thanks for your help #zaccaria
gerhard
(gerhard@ecolar.co.za)
July 19, 2012, 8:53pm
6
Hi
Sorry but I can’t get beginForm() to work with CActiveForm.
Can someone please post an example of a CActiveForm that is distributed over a CJuiTabs.
So the first tab contains the client name; the second tab the client address; etc.
All tabs form part of the same CActiveForm and all tabs are submitted simultaniously via one submit button.
Please provide the complete form (not just the CJuiTabs widget) and the complete partially rendered views (including $form->labelEx, $form->textField and $form->error).
Thanx
softark
(Softark)
July 25, 2012, 9:06am
7
The basic structure should be:
form start
tab start
form fragment 1
form fragment 2
...
tab end
submit button
form end
For example:
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm',
...
);
?>
<?php
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs' => array(
'Form1' => $this->renderPartial('_form1', array('form' => $form, 'model' => $model), true),
'Form2' => $this->renderPartial('_form2', array('form' => $form, 'model' => $model), true),
),
'options' => array(
'collapsible' => true,
),
));
?>
<div class="row buttons">
<?php echo $form->submitButton('Submit'); ?>
</div>
<?php echo $form->errorSummary(array($model)); ?>
<?php $this->endWidget(); ?>
</div><!-- form -->
Note that you can not nest forms like the following:
<form id="a">
<form id="a1">
...
</form>
<form id="a2">
...
</form>
</form>
The partial views for "sub form" should not contain "<form>" tag, because they are not really independent forms but form fragments.
gerhard
(gerhard@ecolar.co.za)
July 26, 2012, 5:42am
8
Thank you softark. It is working now.
Just to recap:
The form fragment "_form1" could be as simple as the following code snippet. It needs nothing more:
<?php echo $form->errorSummary($parent_model); ?>
<div class="row">
<?php echo $form->labelEx($parent_model,'branch_id'); ?>
<?php echo $form->textField($parent_model,'branch_id',array('size'=>10,'maxlength'=>10)); ?>
<?php echo $form->error($parent_model,'branch_id'); ?>
</div>
Most important is:
Besides from passing the model to _form1 in the renderpartial, you also need to pass it the $form parameter (as softark did with ‘form’ => $form), otherwise the above code will not work.
deib97
(Deib97)
October 3, 2013, 5:01am
9
I have problem and show massage like this "Undefined variable: form "??
any clue???
chricris
(Chricris)
June 30, 2014, 7:11pm
11
Thanks @ all
You just made my day.
I was desperate trying to submit several tabs at once. I was not aware that I could hand over the "form" variable to the child view.