我有一个表名business
和一个表名review business
。在business
表中,我只有business name, business image and business information
。在review business
表中我有business_id as foreign key, user_id as foreign key and rate(int) five star and review field
。现在,我可以通过从下拉列表中选择特定的review
,从下拉列表中选择特定的user
然后给{{1}来轻松地为business
提供rate
}和review
。我正在使用dzraty
扩展名。它工作正常。此外,我在reviews
页面上显示了admin
给出的business
。我的问题是user
想要在review
上business
{1}}页面?为此他需要five star rating field and review field
表中的review business
,查看“form
”。我想在商家页面上显示rating
和review
字段,以便用户可以撰写评论并发布。此功能在review business
视图中有效,我只想在另一个视图中使用它。
为了解我发布模型数据。
商业模式
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'addresses' => array(self::HAS_MANY, 'Address', 'business_id'),
'businessItems' => array(self::HAS_MANY, 'BusinessItems', 'business_id'),
'businessPackages' => array(self::HAS_MANY, 'BusinessPackage', 'business_id'),
'facilities' => array(self::HAS_MANY, 'Facilities', 'business_id'),
'reviewBusinesses' => array(self::HAS_MANY, 'ReviewBusiness', 'business_id'),
'subCategoryBusinesses' => array(self::HAS_MANY, 'SubCategoryBusiness', 'business_id'),
);
}
审核商业模式
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'business' => array(self::BELONGS_TO, 'Business', 'business_id'),
'user' => array(self::BELONGS_TO, 'User', 'user_id'),
'profile' => array(self::BELONGS_TO, 'Profiles', 'id','through'=>'user'),
);
}
评论业务的form.php
<?php
/* @var $this ReviewBusinessController */
/* @var $model ReviewBusiness */
/* @var $form BSActiveForm */
?>
<?php $form=$this->beginWidget('bootstrap.widgets.BsActiveForm', array(
'id'=>'review-business-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->labelEx($model,'user_id'); ?>
<?php
$this->widget('ext.select2.ESelect2',array(
'name'=>'ReviewBusiness[user_id]',
'data'=>CHtml::listData(User::model()->findAll(), 'id', 'username'), //the whole available list
'htmlOptions'=>array(
'placeholder'=>' search User name?',
//'options'=>$options, //the selected values
//'multiple'=>'multiple',
'style'=>'width:530px',
),
));
?>
<?php //echo $form->textFieldControlGroup($model,'business_id'); ?>
<div class="gap-small"></div>
<?php echo $form->labelEx($model,'Business_name'); ?>
<?php
$this->widget('ext.select2.ESelect2',array(
'name'=>'ReviewBusiness[business_id]',
'data'=>CHtml::listData(Business::model()->findAll(), 'id', 'business_name'), //the whole available list
'htmlOptions'=>array(
'placeholder'=>' search Business name?',
//'options'=>$options, //the selected values
//'multiple'=>'multiple',
'style'=>'width:530px',
),
));
?>
<div class="gap-small"></div>
<div class="ratings"> <!--use class in order to show rating horizontally -->
<?php
$this->widget('ext.DzRaty.DzRaty', array(
'model' => $model,
'attribute' => 'rating',
)); ?>
</div>
<?php echo $form->textarea($model,'review',array('maxlength'=>500)); ?>
</br>
<?php echo BsHtml::submitButton('Submit', array('color' => BsHtml::BUTTON_COLOR_PRIMARY)); ?>
<?php $this->endWidget(); ?>