public function rules()
{
return [
[['phone', 'phone_other'], 'required', 'when' => function($model) {
return (!$model->phone && !$model->phone_other);
},'whenClient' => 'function(){return false;}',
/*'whenClient' => 'function (attr, value) {
return $("#MODEL-phone").val() == "" && $("#MODEL-phone_other").val() == "";
}', 'message' => 'Заполните "Телефон" или "Доп. Телефон"'*/],
//...
];
}
//Сохранение последовательности выбора
$('#id_select2').on('select2:select', function(e){
var id = e.params.data.id;
var option = $(e.target).children('[value="'+id+'"]');
option.detach();
$(e.target).append(option).change();
});
php composer.phar require la-haute-societe/yii2-save-relations-behavior "*"
class Post extends yii\db\ActiveRecord
{
public function behaviors()
{
return [
'saveRelations' => [
'class' => SaveRelationsBehavior::class,
'relations' => [
'author',
],
],
];
}
}
Setting read-only property
=)$post->author = Author::findOne(2);
$file = \Yii::getAlias('@webroot/archive'.microtime().'.zip');
$zip = new \ZipArchive();
$zip->open($file, \ZIPARCHIVE::CREATE);
$zip->addFile("index.php");//добавляем файлы в архив
$zip->close();
if (file_exists($file)) {
\Yii::$app->response->sendFile($file, 'archive.zip');
ignore_user_abort(true);//удаление временного файла
if (connection_aborted()) unlink($file);
register_shutdown_function('unlink', $file);
}
$.ajax({
'success': function(data){
var targets = [
'#container1',
'#container2'
];
$.each(targets, function (ind, t) {
$(t).html($(data).find(t).html());
});
}
});
$.pjax.reload({container: "#container1", async:false});
$.pjax.reload({container: "#container2", async:false});
$.ajax({
'success': function(data){
var targets = [
'#container1',
'#container2'
];
$.each(targets, function (ind, t) {
$(t).html($(data).find(t).html());
});
}
});
$.pjax.reload({container: "#container1", async:false});
$.pjax.reload({container: "#container2", async:false});
free -h
php composer.phar require bower-asset/font-awesome
namespace app\assets;
use yii\web\AssetBundle;
class FontAwesomeAsset extends AssetBundle
{
public $sourcePath = '@bower/font-awesome';
public $css = [
'css/all.min.css',
];
}
\app\assets\FontAwesomeAsset::register($this);
class AppAsset extends AssetBundle
{
...
public $depends = [
'app\assets\FontAwesomeAsset',
...
];
}
public $jsOptions = [
'position' => \yii\web\View::POS_HEAD,
];
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 20
],
]);
//Этот код располагать ниже всех операций с $query
if(!Yii::$app->request->get('page')){
$dataProvider->pagination->page = ceil($dataProvider->getTotalCount() / $dataProvider->pagination->pageSize) - 1;
}
"dektrium/yii2-user": "dev-master",
и composer подтянет ветку "master" вашего fork."repositories": [
{
"type": "vcs",
"url": "https://github.com/Leopandro/yii2-user"
}
],
"require": {
"dektrium/yii2-user": "dev-master",
},
php composer.phar update dektrium/yii2-user