rules => [
'<_c:[\w]+>/<_a:[\w]+>/<id:\d+>' => '<_c>/view'
]
$array = explode('/\s*\n\s*/', trim($title));
foreach ($array as $valued ) {
JBase::Query("INSERT IGNORE INTO `qeo` (`title`, `published`, `order` , `parent`) VALUES ('" . $valued . "', '1','1','" . $parent . "')");
}
<?= $form->field($model, 'country_id')->dropDownList(ArrayHelper::map(Countries::getAllName(), 'id', 'name_ru'),
[
'prompt' => 'Выбрать страну...',
'onchange' => '
$.post(
"'.Url::toRoute('ajax/list').'",
{id : $(this).val()},
function(data){
$("select#regions").html(data).attr("disabled", false)
}
)
'
]);
//это взаимосвязанный выпадающий список, куда будет подставлен результат работы ajajx
<?= $form->field($model, 'region_id')->dropDownList(ArrayHelper::map(Regions::getAllName(), 'id', 'name_ru'),
[
'prompt' => 'Выбрать регион...',
'id' => 'regions',
'disabled' => $model->isNewRecord ? 'disabled' : false
])
public function actionList()
{
if(Yii::$app->request->isAjax)
{
$id = (int)Yii::$app->request->post('id');
$regions = Regions::find()
->where('status=:status',[':status' => Regions::STATUS_ACTIVE])
->andWhere('country_id=:id', [':id' => $id])
->orderBy('name_ru')
->all();
foreach($regions as $region){
$this->option .= '<option value="'.$region->id.'">'.$region->name_ru.'</option>';
}
}
return $this->option;
}
public function attributeLabels()
{
return ArrayHelper::merge(parent::attributeLabels(),[
'newPassword' => 'Новый пароль',
'newPasswordRepeat' => 'Повторить новый пароль'
]);
}
use yii\behaviors\TimestampBehavior;
public function behaviors()
{
return [
TimestampBehavior::className()
];
}
public function getVideos()
{
return $this->owner->hasMany($this->className, [$this->attribute => 'id'])->where([/* тут Ваше условие */]);
}
string()->notNull();
if($transfer->save()){
// какое-то действие
}
else{
// показать все ошибки
}
$transfer->created_at = time();
use yii\behaviors\TimestampBehavior;
public function behaviors()
{
return [
TimestampBehavior::className()
];
}