Example #1
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $model = Yii::createObject(['class' => Message::className(), 'author_id' => $this->userId, 'recipient_id' => $this->contactId]);
     $options = ArrayHelper::merge($this->options, ['id' => $this->id, 'data' => ['pjax' => $this->pjaxId, 'fancy' => $this->fancySelector]]);
     $formOptions = ArrayHelper::merge(['id' => "{$this->id}-form", 'action' => Yii::$app->urlManager->createUrl($this->route), 'enableClientValidation' => true, 'enableAjaxValidation' => false, 'validateOnSubmit' => true], $this->formOptions);
     if ($this->fancySelector) {
         echo \newerton\fancybox\FancyBox::widget(['target' => $this->fancySelector, 'config' => array_merge(['href' => '#' . $this->id, 'autoDimensions' => false, 'autoSize' => false, 'width' => 500, 'height' => 200, 'type' => 'inline'], $this->fancyOptions)]);
         Html::addCssStyle($options, 'display:none');
     }
     return $this->render($this->tpl, ['id' => $this->id, 'model' => $model, 'options' => $options, 'formOptions' => $formOptions]);
 }
Example #2
0
 /**
  * Relation with last message
  * @return \yii\db\ActiveQuery
  */
 public function getLastMessage()
 {
     return $this->hasOne(Message::className(), ['id' => 'last_message_id']);
 }