class EventsSponsor_yii2 extends ActiveRecord
{
public static $image_dir = 'media/events/';
public $imageUpload;
/**
* @return string the associated database table name
*/
public static function tableName()
{
return 'events_sponsor';
}
/**
* @return array validation rules for model attributes
*/
public function rules()
{
return [
[['image'], 'required'],
[['description'], 'string', 'max' => 1000],
];
}
}
<div class="form-group field-image has-success">
<label class="control-label" for="image">Картинка</label>
<input type="hidden" name="EventsSponsor_yii2[image]" value="">
<input type="file" id="image" name="EventsSponsor_yii2[image]" value="media/events/58342/8137-email7a3ed7a035e73385bad43535bbad90d5_size225x225.png" aria-invalid="false">
<div class="help-block"></div>
</div>
'q_comp' => array(self::HAS_ONE, 'Questions', array('event_id'=>'event_id'),'on' => 'q_comp.link_company=1'),
'q_ans_comp' => array(self::HAS_ONE, 'QuestionAnswers', array('event_id'=>'event_id'), 'on' => 'q_ans_comp.question_id=q_comp.id AND q_ans_comp.question_user_id=QuestionUsers .id', 'through'=>'q_comp'),
Но может еще какое решение имеется