Hi Guys!
First I wanna say hello to everyone, 'cause this is my first post here
I’ve already created a model for DB table. Now I created a custom form, with who I want to get some data for a custom query (get email address for particular ‘addid’ which is primary key stored in email column) . I wanted to send mail by using contact form to the related email address for the ‘addid’ in the table.
for this, I created contactpublisher.php in the view of model.
my model is Add controller is AddController view is add/contactpublisher.php
view code contactpublisher.php
<?php
/* @var $this SiteController */
/* @var $model ContactForm */
/* @var $form TbActiveForm */
$this->pageTitle=Yii::app()->name . ' - Contact Add Publisher';
$this->breadcrumbs=array(
'Contact',
);
?>
<h2>Contact Add Publisher</h2>
<?php if(Yii::app()->user->hasFlash('contact')): ?>
<?php $this->widget('bootstrap.widgets.TbAlert', array(
'alerts'=>array('contact'),
)); ?>
<?php else: ?>
<p>
If you have business inquiries, 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'=>'contact-form',
'type'=>'horizontal',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
)); ?>
<?php echo "<br>"; ?>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->textFieldRow($model,'name'); ?>
<?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; ?>
I put the link for contactpublisher form in the view of add:- view.php as
<?php
$this->menu=array(
array('label'=>'Contact Add Owner', 'url'=>array('contactpublisher', 'id'=>$model->addid)),
);
?>
my question is how to find the email address saved in table for the particular addid, I already tried this by using
$mailid=Add::model()->findByPk($addid);
but this is not working at all.
maybe someone can help me out with a small snippet
cheers and thanks to everyone in advance!!