I have created contactowner.php view to generate contact form same as default contact form created by yii app.
purpose is to create and render that contact form into the view of the adds model. (for each add displayed in view.php )
it display the form in the view for each adds but its not working at all when submit button is pressed.
contactowner.php
<p>For business inquiries or other questions, please fill out the following form to contact the publisher of this add.
</p>
<div class="form">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'contactowner',
'type'=>'horizontal',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
<?php echo "<br>"; ?>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->textFieldRow($model,'name',array('size'=>50,'maxlength'=>50,'value'=>Yii::app()->user->name,'disabled'=>'disabled')); ?>
<?php echo $form->textFieldRow($model,'email'); ?>
<?php echo $form->textFieldRow($model,'subject',array('size'=>60,'maxlength'=>128)); ?>
<?php echo $form->textAreaRow($model,'body',array('rows'=>4, 'class'=>'span5')); ?>
<div class="form-actions">
<?php $this->widget('bootstrap.widgets.TbButton',array(
'buttonType'=>'submit',
'type'=>'primary',
'size'=>'large',
'label'=>'Submit',
)); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<?php endif; ?>
controller code—
public function actionContactowner()
{
$model=new ContactForm;
if(isset($_POST['Shops']))
{
$model->attributes=$_POST['Shops'];
if($model->validate())
{
$name='=?UTF-8?B?'.base64_encode($model->name).'?=';
$subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';
$headers="From: $name <{$model->email}>\r\n".
"Reply-To: {$model->email}\r\n".
"MIME-Version: 1.0\r\n".
"Content-type: text/plain; charset=UTF-8";
mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contactowner',array('model'=>$model));
}
what is wrong in that code… help me please… thanks…