hi guys
I am newbie in yii and php, so please help me answer my problem
I have follow this link http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models/, but in _form.php, there something confused.
it about the sentences …input fields for $a, $b… in that link. what is mean?
I have try like this
<?php echo $form->errorSummary(array($model,$model2)); ?>
<div class="row">
<?php echo $form->labelEx($model,$model2,'ktp'); ?>
<?php echo $form->textField($model,$model2,'ktp',array('size'=>20,'maxlength'=>20)); ?>
<?php echo $form->error($model,$model2,'ktp'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton ($model,$model2->isNewRecord ? 'Create' : 'Save'); ?>
</div>
I got this error
strpos() expects parameter 1 to be string, object given
but, when I write this code
<?php echo $form->errorSummary(array($model,$model2));
<div class="row">
<?php echo $form->labelEx(array($model,$model2),'ktp'); ?>
<?php echo $form->textField(array($model,$model2),'ktp',array('size'=>20,'maxlength'=>20)); ?>
<?php echo $form->error(array($model,$model2),'ktp'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton (array($model,$model2->isNewRecord ? 'Create' : 'Save')); ?>
</div>
I just got the blank page written Create Client
What wrong?
I use yii 1.1.7
and my controller syntax is
public function actionCreate()
{
$model=new Client;
$model2=new DataMohon;
if(isset ($_POST['Client'], $_POST['DataMohon']))
{
$model->attributeLabels=$_POST['Client'];
$model2->attributeLabels=$_POST['DataMohon'];
$valid=$model->validate();
$valid=$model2->validate() && $valid;
if($valid)
{
$model->save(false);
$model2->save(false);
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('create', array(
'model'=>$model,
'model2'=>$model2,
));
}
I have try to search this question, but I have not found yet, my apologise if this problem have an answer, just show me that link.
sorry about my poor language
thanks guys for your help