Hi there,
I am new to Yii and am stuck here. I have two models : Post and Tag,
What I want to do is put another TextArea in the Post Create Form which would get the Tags and store them in the Tag model.
This is my _form.php for the post create :
<?php
/* @var $this PostController */
/* @var $model Post */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'post-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'title'); ?>
<?php echo $form->textField($model,'title',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model,'title'); ?>
</div>
<script src="<?php echo Yii::app()->baseUrl.'/ckeditor/ckeditor.js'; ?>"></script>
<div class="row">
<?php echo $form->labelEx($model,'post'); ?>
<?php echo $form->textArea($model,'post',array('id'=>'editor1')); ?>
<?php echo $form->error($model,'post'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'status'); ?>
<?php echo $form->dropDownList($model,'status',$model->getStatusType()); ?>
<?php echo $form->error($model,'status'); ?>
</div>
<script type="text/javascript">
CKEDITOR.replace( 'editor1' );
</script>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
I tried adding this to the above code :
<div class="row">
<?php echo $form->labelEx($model,'tags'); ?>
<?php echo $form->textField($model,'tags',array('size'=>45,'maxlength'=>45)); ?>
<?php echo $form->error($model,'tags'); ?>
</div>
Now I want to add another textArea to this that would get the tags and store them to the Tag model. I tried to change the actionCreate() method in my PostController but still I was getting a Post.tags is not defined error.
I even added this method in the Post model :
public function addTags($tags){
$tags->id = $this->id;
return $tags->save();
}
But still its giving me errors.