I am trying to update data but when i click on the submit button all i get is Bad request (#400) missing required parameter: id. It was working on the previous project and all the files are created by Gii CRUD. I have the same issue when i am trying to create data but guess i am making same mistake with it. What is wrong? What i am doing wrong?Thank you in advance!
View:
<?php $form = ActiveForm::begin([
'id' => 'update-form'
]); ?>
<?php $languages = Lang::find()->all(); ?>
<ul class="nav nav-tabs">
<?php
foreach ($languages as $key => $language) {
if ($language->default == 1) {
echo '<li class="active"><a data-toggle="tab" href="#' . $key . '">' . $language->name . '</a></li>';
} else {
echo '<li><a data-toggle="tab" href="#' . $key . '">' . $language->name . '</a></li>';
}
}
?>
</ul>
<div class="tab-content">
<?php
foreach ($languages as $key => $language) {
if ($language->default != 1) {
echo '<div id="' . $key . '" class="tab-pane fade">';
echo '<div class="row">';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'title_' . $language->url)->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'url_' . $language->url)->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '</div>';
echo '<div class="row">';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'meta_title_' . $language->url)->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'meta_description_' . $language->url)->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '<div col-xs-12><div class="form-group">';
$textContent = 'content_' . $language->url;
if (!$model->isNewRecord) {
$model->$textContent = OutData::showTXT($model->$textContent);
}
echo $form->field($model, 'content_' . $language->url)->textarea();
echo "<script>
CKEDITOR.replace( 'Page[content_$language->url]' );
</script>";
echo '</div></div>';
echo '</div>';
} else {
echo '<div id="' . $key . '" class="tab-pane fade in active">';
echo '<div class="row">';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'title')->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'url')->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '</div>';
echo '<div class="row">';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'meta_title')->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '<div class="col-sm-6"><div class="form-group">';
echo $form->field($model, 'meta_description')->widget(RemainingCharacters::classname(), [
'type' => RemainingCharacters::INPUT_TEXT,
'text' => Yii::t('app', '{n} characters remaining'),
'label' => [
'tag' => 'p',
'id' => 'my-counter',
'class' => 'myCounter',
'invalidClass' => 'error'
],
'options' => [
'class' => 'form-control',
'maxlength' => true,
]
]);
echo '</div></div>';
echo '<div class="col-xs-12"><div class="form-group">';
if (!$model->isNewRecord) {
$model->content = OutData::showTXT($model->content);
}
echo $form->field($model, 'content')->textarea();
echo "<script>
CKEDITOR.replace( 'Page[content]' );
</script>";
echo '</div></div>';
echo '</div>';
}
echo '</div>';
}
?>
</div>
<div class="row">
<div class="col-sm-6">
<?php
$mas[0] = Yii::t('app', 'Главна страница');
$mas['----------------'] = ArrayHelper::map(Page::find()->where('id_in=0 and is_cat=1')->all(), 'id', 'title');
?>
<?=
$form->field($model, 'id_in')->widget(Select2::classname(), [
'model' => $model,
'attribute' => 'id_in',
'data' => $mas,
'options' => [
'placeholder' => Yii::t('app', 'Select a type ...'),
],
'pluginOptions' => [
'allowClear' => true
],
])
?>
</div>
<div class="col-sm-6">
<?php
if ($model->isNewRecord) {
echo $form->field($model, 'view_id')->hiddenInput(['value' => 12])->label(false);
} else {
echo $form->field($model, 'view_id')->hiddenInput(['value' => $model->view_id])->label(false);
}
?>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<?= $form->field($model, 'sort')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<?= $form->field($model, 'active')->hiddenInput(['value' => ($model->active) ? $model->active : 2])->label(false) ?>
<?= Html::activeLabel($model, 'active', ['class' => 'dblock flLeft mr5 pt5']); ?>
<label class="switch switch-custom block dblock flLeft">
<input type="checkbox" value="1" id="active_<?= $model->id ?>"class="legend-switch" <?= ($model->active == 1) ? 'checked="checked"' : '' ?> onchange="changeHiddenField('page-active', 'active_<?= $model->id ?>');"></input>
<label data-off="<?= Yii::t('app', 'Не'); ?>" data-on="<?= Yii::t('app', 'Да') ?>" for="active_<?= $model->id ?>"></label>
</label>
</div>
<div class="col-sm-3">
<?= $form->field($model, 'in_main_menu')->hiddenInput(['value' => ($model->in_main_menu) ? $model->in_main_menu : 2])->label(false) ?>
<?= Html::activeLabel($model, 'in_main_menu', ['class' => 'dblock flLeft mr5 pt5']); ?>
<label class="switch switch-custom block dblock flLeft">
<input type="checkbox" value="1" id="in_main_menu_<?= $model->id ?>"class="legend-switch" <?= ($model->in_main_menu == 1) ? 'checked="checked"' : '' ?> onchange="changeHiddenField('page-in_main_menu', 'in_main_menu_<?= $model->id ?>');"></input>
<label data-off="<?= Yii::t('app', 'Не'); ?>" data-on="<?= Yii::t('app', 'Да') ?>" for="in_main_menu_<?= $model->id ?>"></label>
</label>
</div>
<div class="col-sm-3">
<?= $form->field($model, 'in_side_menu')->hiddenInput(['value' => ($model->in_side_menu) ? $model->in_side_menu : 2])->label(false) ?>
<?= Html::activeLabel($model, 'in_side_menu', ['class' => 'dblock flLeft mr5 pt5']); ?>
<label class="switch switch-custom block dblock flLeft">
<input type="checkbox" value="1" id="in_side_menu_<?= $model->id ?>"class="legend-switch" <?= ($model->in_side_menu == 1) ? 'checked="checked"' : '' ?> onchange="changeHiddenField('page-in_side_menu', 'in_side_menu_<?= $model->id ?>');"></input>
<label data-off="<?= Yii::t('app', 'Не'); ?>" data-on="<?= Yii::t('app', 'Да') ?>" for="in_side_menu_<?= $model->id ?>"></label>
</label>
</div>
<?= $form->field($model, 'is_cat')->hiddenInput(['value' => ($model->is_cat) ? $model->is_cat : 0])->label(false) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'app.Create') : Yii::t('app', 'app.Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
Controller:
public function actionUpdate($id) {
$model = $this->findModel($id, true);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model = $this->findModel($model->id, true);
$languages = Lang::find()->all();
foreach ($languages as $language) {
if ($language->default != 1) {
$title = 'title_' . $language->url;
// $url = MakeURL::parseUrl($model->$title, $model->id);
$urlName = 'url_' . $language->url;
if($model->old_link == 1){
$model->$urlName = MakeURL::parseUrl($model->$urlName, $model->id);
}else{
$model->$urlName = MakeURL::parseUrlGoogle($model->$urlName, $model->id);
}
$content = 'content_' . $language->url;
$var = Yii::$app->OutData->sanitize($model->$content);
$model->$content = $var;
} else {
// $url1 = MakeURL::parseUrl($model->title, $model->id);
if($model->old_link == 1){
$model->url = MakeURL::parseUrl($model->url, $model->id);
}else{
$model->url = MakeURL::parseUrlGoogle($model->url, $model->id);
}
$model->content = Yii::$app->OutData->sanitize($model->content);
}
}
$model->dt_update = date('Y-m-d H:i:s');
$model->update_user_id = Yii::$app->user->identity->id;
$model->save();
//return $this->redirect(['index']);
return $this->redirect([Yii::$app->session['ReturnUrl']]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
public function actionUpdate($id) {
This action expects a required parameter $id when it's called but you're not passing it (it goes something like index.php?r=site/update but it should be like this: index.php?r=site/update&id=10). Solution to that problem is to add the following line to ActiveForm parameters:
'action' => Url::to(['site/update', 'id' => $id]),
Where $id is the ID of the model. And this makes:
<?php
$form = ActiveForm::begin([
'id' => 'update-form',
'action' => Url::to(['site/update', 'id' => $id]),
]); ?>
Sorry in advance if this is defined somewhere else, I haven't look at a whole code.
Related
i'd like to ask how to retrieving data as array from gridview
as mentioned in this thread
How can I get the selected data/item rows in CheckboxColumn Gridview - Yii2
what i have been doing is :
in the controller
public function actionCetakdispo{
$action=Yii::$app->request->post('action');
$selection=(array)Yii::$app->request->post('selection');
print_r($selection);
exit;
}
in view :
<?=Html::beginForm(['controller/rekapsm'],'post');?>
<?= Html::a('Cetak Dispo', ['cetakdispo'], ['class' => 'btn btn-
primary']) ?>
<?= Html::a('Cetak Register', ['cetakreg'], ['class' => 'btn btn-
primary']) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'kategori',
'nama_wp',
'nama',
'nomor_surat',
'tgl_surat',
'perihal',
'ket',
['class' => 'yii\grid\CheckboxColumn'],
],
]); ?>
but nothing data retrieve to array..please give me lessons or referrence to read..many thanks..
UPDATED :
i change view become likethis :
<div class="row" style="margin-left:870px;" >
<?=Html::beginForm(['cetakdispo'],'post');?>
<?=Html::submitButton('Cetak Dispo', ['class' => 'btn btn-primary']);?>
<?= Html::a('Cetak Register', ['cetakreg'], ['class' => 'btn btn-primary']) ?>
</div>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn',],
'id',
'kategori',
'nama_wp',
'nama',
'nomor_surat',
'tgl_surat',
'perihal',
'ket',
['class' => 'yii\grid\CheckboxColumn', 'checkboxOptions' => function($model, $key, $index, $widget) {
return ['value' => $model['id'] ];
},],
],
]); ?>
<?= Html::endForm();?>
</div>
and its works...
i want add uploadFile to: https://github.com/thyseus/yii2-message
i added public $file2 in Message.php in model
and this is my rules in model:
public function rules()
{
return [
[['title'], 'required'],
[['file2'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg'],
[['title', 'message', 'context'], 'string'],
[['title'], 'string', 'max' => 255],
[['to'], IgnoreListValidator::class],
[['to'], 'exist',
'targetClass' => Yii::$app->getModule('message')->userModelClass,
'targetAttribute' => 'id',
'message' => Yii::t('app', 'Recipient has not been found'),
],
[['to'], 'required', 'when' => function ($model)
{
return $model->status != Message::STATUS_SIGNATURE && $model->status != Message::STATUS_DRAFT;
}],
];
}
and this is my view:
<?= $form->field($model, 'message')->textarea(['rows' => 6]) ?>
<?php
echo $form->field($model, 'file2')->widget(FileInput::classname(), [
'options' => ['accept' => 'image/*'],
]);
// With model & without ActiveForm
echo '<label class="control-label">Add Attachments</label>';
echo FileInput::widget([
'model' => $model,
'attribute' => 'file2',
'options' => ['multiple' => true]
]);
?>
and this is my sendMessage Function
$model = new Message();
$model->attributes = $attributes;
var_dump($attributes);
die;
why after upload file my result is this?
array(4) { ["to"]=> array(1) { [0]=> string(2) "65" } ["title"]=> string(3) "asd" ["message"]=> string(30) "asd . " ["file2"]=> string(0) "" }
file2 is empty !
When setting up the form, you need to mention as multipart/form-data. check below example.
<?php
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model, 'file2')->fileInput() ?>
<button>Submit</button>
<?php ActiveForm::end() ?>
How to save same name but different content for example, samplename.docx. Now i want to save it again but the result the same. When i create a new report and use the name samplename it will overwrite the other same name. So in the uploads folder the samplename.docx is only one. But in the dgView is more than one.
This is my controller:
public function actionCreate()
{
$model = new reportDetails();
if ($model->load(Yii::$app->request->post()))
{
$project =$model->doc_name;
$model->upload_file= UploadedFile::getInstance($model,'doc_file');
$model->upload_file->saveAs('uploads/'.$project.'.'.$model->upload_file->extension);
$model->doc_file='uploads/'.$project.'.'.$model->upload_file->extension;
$model->doc_name=$project.'.'.$model->upload_file->extension;
$model->save();
Yii::$app->getSession()->setFlash('success','Data saved!');
return $this->redirect(['view','id'=> $model->report_id]);
}
else {
return $this ->render('create', [
'model'=>$model,
]);
}
}
This is my model:
public $upload_file;
public function rules()
{
return [
[['reference_no', 'subject', 'doc_for', 'doc_from', 'doc_date', 'doc_file', 'doc_name', 'drawer_id'], 'required'],
[['doc_date'], 'safe'],
[['drawer_id'], 'integer'],
[['reference_no', 'doc_for', 'doc_from'], 'string', 'max' => 200],
[['subject'], 'string', 'max' => 255],
[['doc_file', 'doc_name'], 'string', 'max' => 50],
[['user_id'],'string'],
];
}
/**
* #inheritdoc
*/
public function attributeLabels()
{
return [
'report_id' => 'Report ID',
'reference_no' => 'Reference No:',
'subject' => 'Subject:',
'doc_for' => 'For:',
'doc_from' => 'From:',
'doc_date' => 'Document Entry Date:',
'doc_file' => 'Document File:',
'doc_name' => 'Document Name:',
'drawer_id' => 'Drawer ID:',
'user_id' => 'Encoder Name:',
];
}
And this is my form:
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?= Html::button('<i class="fa fa-plus"></i> Add Person', ['value' => Url::to('index.php?r=name/create'), 'class' => 'btn btn-custom-pos btn-success', 'id' => 'officialsfor']) ?>
</br>
</br>
<?php Pjax::begin(['id' => 'for_from']) ?>
<div class="col-sm-6">
<?= $form->field($model, 'doc_for')->widget(Select2::classname(), [
'data' => ArrayHelper::map(Name::find()->asArray()->all(),
'name_id',
function($model, $defaultValue){
return $model['position'].' '.$model['fname'].' '.$model['mname'].' '.$model['lname'];
}),
'language' => 'en',
'options' => ['placeholder' => 'Choose a person ...'],
'pluginOptions' => [
'allowClear' => true,
'width' => 500,
],
]); ?>
</div>
<div class="col-sm-6">
<?= $form->field($model, 'doc_from')->widget(Select2::classname(), [
'data' => ArrayHelper::map(Name::find()->asArray()->all(),
'name_id',
function($model, $defaultValue){
return $model['position'].' '.$model['fname'].' '.$model['mname'].' '.$model['lname'];
}),
'language' => 'en',
'options' => ['placeholder' => 'Choose a person ...'],
'pluginOptions' => [
'allowClear' => true,
'width' => 500,
],
]); ?>
<?php Pjax::end(); ?>
</div>
</br>
</br></br></br>
<div class="broder" style=" border-radius: 5px; padding: 12px; ">
</div>
<div class="col-sm-6">
<?= $form->field($model, 'user_id')->textInput(['type' => 'hidden','style'=>'width:500px;','placeholder' => 'Enter a Reference No....','value' =>ucfirst(Yii::$app->user->identity->first_name) . ' ' . ucfirst(Yii::$app->user->identity->middle_name) . ' ' . ucfirst(Yii::$app->user->identity->last_name)]) ?>
<?= Html::activeLabel($model, 'user_id', ['label'=>ucfirst(Yii::$app->user->identity->first_name) . ' ' . ucfirst(Yii::$app->user->identity->middle_name) . ' ' . ucfirst(Yii::$app->user->identity->last_name),'style' => 'font-size: 21px;','class' => 'color']) ?>
<br>
<br>
<?= $form->field($model, 'reference_no')->textInput(['style'=>'width:500px','placeholder' => 'Enter a Reference No....']) ?>
<?= $form->field($model, 'subject')->textInput(['maxlength'=>true,'style'=>'width:500px','placeholder' => 'Enter a Subject....']) ?>
<?= $form->field($model, 'doc_date')->widget(
DatePicker::className(), [
'inline' => false,
'options' => ['placeholder' => 'Choose a Entry Date ...'],
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-mm-dd'
]
]);?>
</div>
<div class="col-sm-6" style="padding-top: 14px; ">
</br>
</br>
</br></br>
<?= $form->field($model, 'drawer_id')->textInput(['maxlength'=>true,'style'=>'width:500px','placeholder' => 'Enter a Drawer ID....', ]) ?>
<?= $form->field($model, 'doc_name')->textInput(['maxlength'=>true,'style'=>'width:500px','placeholder' => 'Enter a Document Name....']) ?>
<?= $form->field($model, 'doc_file')-> widget(
FileInput::classname(),[
'name' => 'doc_file',
'options' => ['accept' => '.docx','.doc','.docs'],
'pluginOptions' => [
'showPreview' => false,
'showCaption' => true,
'showRemove' => true,
'showUpload' => false
]
]);
?>
use
if(file_exists('...')){
// upload file with , new file name
}
else{
// upload file
}
Try this one
if (file_exists($fileFullPath)) {
unlink ($fileFullPath);
echo "delete existing file creating new <br />";
}else{
echo "file not exists creating new <br />";
}
I use http://demos.krajee.com/widget-details/select2#usage-tags
controller
public function actionTagsForm()
{
$method = Yii::$app->request->isAjax ? 'renderAjax' : 'render';
$model = new UserTagsForm();
return $this->$method('tagsForm', ['model' => $model]);
}
views/layouts/main.php has code modal window
<?php
yii\bootstrap\Modal::begin([
'header' => '<div id="modalHeader"></div>',
'id' => 'modal',
'size' => 'modal-lg',
'options' => [
'tabindex' => false
],
]);
echo "<div id='modalContent'></div>";
yii\bootstrap\Modal::end();
?>
view
$data = [
"red" => "red",
"green" => "green",
"blue" => "blue",
"orange" => "orange",
"white" => "white",
"black" => "black",
"purple" => "purple",
"cyan" => "cyan",
"teal" => "teal"
]; ?>
<div class="image-tags-index">
<?php $form = ActiveForm::begin();?>
<?php echo $form->field($model, 'image_tags')->widget( Select2::classname(),[
'data' => $data,
'options' => ['placeholder' => 'Select a state ...'],
'pluginOptions' => [
'allowClear' => true
],
])->label('Tag Multiple');
?>
</div>
error
VM314:2 Uncaught ReferenceError: select2_3f25e3ac is not defined
at eval (eval at globalEval (jquery.js:343), :2:56)
at eval ()
at Function.globalEval (jquery.js:343)
at domManip (jquery.js:5291)
at jQuery.fn.init.append (jquery.js:5431)
at jQuery.fn.init. (jquery.js:5525)
at access (jquery.js:3614)
at jQuery.fn.init.html (jquery.js:5492)
at Object. (jquery.js:9436)
at fire (jquery.js:3187)
This problem has been solved in the https://github.com/kartik-v/yii2-widget-select2/issues/211
Contents are going under the top Navigation bar. Sometimes it shows right. Sometimes the problem occurs. Please help. Attaching picture of the error page.I am giving my views/layout/main file below. The content of the page is a bit in upward direction.
<?php
/* #var $this \yii\web\View */
/* #var $content string */
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use common\widgets\Alert;
use kartik\sidenav\SideNav;
use yii\helpers\Url;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => 'GM Pharmaceuticals',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = [
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']
];
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
NavBar::end();
?>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<div class="container-fluid">
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= Alert::widget() ?>
<div class="col-xs-4 col-sm-4 col-lg-2" style="padding-left: 0px;">
<?php
echo SideNav::widget([
'type' => SideNav::TYPE_DEFAULT,
'heading' => '<i class="glyphicon glyphicon-cog"></i> Menu',
'items' => [
[
'url' => Yii::$app->homeUrl,
'label' => 'Home',
'icon' => 'home',
],
[
'label' => 'Product',
'icon' => 'glyphicon glyphicon-baby-formula',
//'visible'=>Yii::$app->user->can('s_add-parties'),
'items' => [
[
'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=batchno/productbatch/create',
'label' => 'New Batch',
'icon' => 'glyphicon glyphicon-plus-sign',
'visible'=>Yii::$app->user->can('c_billing-person'),
],
[
'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=batchno/productbatch',
'label' => 'Edit Batch',
'icon' => 'glyphicon glyphicon-edit',
'visible'=>Yii::$app->user->can('c_billing-person'),
],
],
],
[
'label' => 'Party',
'icon' => 'glyphicon glyphicon-user',
//'visible'=>Yii::$app->user->can('s_add-parties'),
'items' => [
[
'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=Parties/parties',
'label' => 'New Party',
'icon' => 'glyphicon glyphicon-plus-sign',
'visible'=>Yii::$app->user->can('s_add-parties'),
],
],
],
[
'url' => 'http://localhost:8080/advanced/backend/web/index.php?r=tc/bills',
'label' => 'Transport',
'icon' => 'glyphicon glyphicon-send',
'visible'=>Yii::$app->user->can('c_billing-person'),
],
[
'label' => 'Payment',
'icon' => 'glyphicon glyphicon-piggy-bank',
'visible'=>Yii::$app->user->can('c_payment-collection'),
'items' => [
[
//'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=payment/payment',
'label' => 'Gopalbabu',
'icon' => 'glyphicon glyphicon-usd',
'visible'=>Yii::$app->user->can('s_create-payment'),
'items' =>[
[
'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=payment/payment/create',
'label' => 'New',
'icon' => 'glyphicon glyphicon-plus-sign',
'visible'=>Yii::$app->user->can('s_create-payment'),
],
[
'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=payment/payment',
'label' => 'View & Update',
'icon' => 'glyphicon glyphicon-edit',
'visible'=>Yii::$app->user->can('s_create-payment'),
],
],
],
[
//'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=sbp/payments',
'label' => 'Sanatbabu',
'icon' => 'glyphicon glyphicon-usd',
'visible'=>Yii::$app->user->can('s_create-payment'),
'items' =>[
[
'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=sbp%2Fpayments%2Fcreate',
'label' => 'New',
'icon' => 'glyphicon glyphicon-plus-sign',
'visible'=>Yii::$app->user->can('s_create-payment'),
],
[
'url' => 'http://localhost:8080/advanced/frontend/web/index.php?r=sbp/payments',
'label' => 'View & Update',
'icon' => 'glyphicon glyphicon-edit',
'visible'=>Yii::$app->user->can('s_create-payment'),
],
],
],
],
],
[
'label' => 'Help',
'icon' => 'question-sign',
'items' => [
['label' => 'About', 'icon'=>'info-sign', 'url'=>'#'],
['label' => 'Contact', 'icon'=>'phone', 'url'=>'#'],
],
],
],
]);
?>
</div>
<div class="col-xs-8 col-sm-8 col-lg-10" style="padding-left: 0px;">
<?= $content ?>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-left">© My Company <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
I guess you have missed a <div>,
try <br> tag after main div in views/layout/main.php
or check one by one all divs starting and closing properly.
I found the solution. I changed <div class="container-fluid"> to <div class="container"> and it worked.