Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
test-project
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Junaid Rahman pv
test-project
Commits
da370fae
Commit
da370fae
authored
Sep 09, 2016
by
dianc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Category Files changes
parent
804166af
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
54 deletions
+52
-54
CategoryController.php
backend/modules/theme/controllers/CategoryController.php
+52
-53
index.php
backend/modules/theme/views/category/index.php
+0
-1
No files found.
backend/modules/theme/controllers/CategoryController.php
View file @
da370fae
...
...
@@ -156,8 +156,7 @@ class CategoryController extends Controller
if
(
$flag
)
{
$transaction
->
commit
();
return
$this
->
redirect
([
'file'
,
'category_id'
=>
$model
->
id
]);
return
$this
->
redirect
([
'index'
,
'category_id'
=>
$model
->
id
]);
}
}
catch
(
Exception
$e
)
{
$transaction
->
rollBack
();
...
...
@@ -189,55 +188,55 @@ class CategoryController extends Controller
}
}
public
function
actionCreatee
()
{
$model
=
new
Category
();
$modelFiles
=
[
new
CategoryFiles
()];
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
$modelFiles
=
Model
::
createMultiple
(
CategoryFiles
::
classname
());
Model
::
loadMultiple
(
$modelFiles
,
Yii
::
$app
->
request
->
post
());
// ajax validation
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
return
ArrayHelper
::
merge
(
ActiveForm
::
validateMultiple
(
$modelFiles
),
ActiveForm
::
validate
(
$model
)
);
}
// validate all models
$valid
=
$model
->
validate
();
$valid
=
Model
::
validateMultiple
(
$modelFiles
)
&&
$valid
;
if
(
$valid
)
{
$transaction
=
\Yii
::
$app
->
db
->
beginTransaction
();
try
{
if
(
$flag
=
$model
->
save
(
false
))
{
foreach
(
$modelFiles
as
$modelFile
)
{
$modelFile
->
category_id
=
$model
->
id
;
if
(
!
(
$flag
=
$modelFile
->
save
(
false
)))
{
$transaction
->
rollBack
();
break
;
}
}
}
if
(
$flag
)
{
$transaction
->
commit
();
return
$this
->
redirect
([
'file'
,
'category_id'
=>
$model
->
id
]);
}
}
catch
(
Exception
$e
)
{
$transaction
->
rollBack
();
}
}
}
return
$this
->
render
(
'file'
,
[
'model'
=>
$model
,
'modelFiles'
=>
(
empty
(
$modelFiles
))
?
[
new
CategoryFiles
()]
:
$modelFiles
]);
}
//
public function actionCreatee()
//
{
//
$model = new Category();
//
$modelFiles = [new CategoryFiles()];
//
if ($model->load(Yii::$app->request->post())) {
//
//
$modelFiles = Model::createMultiple(CategoryFiles::classname());
//
Model::loadMultiple($modelFiles, Yii::$app->request->post());
//
//
// ajax validation
//
if (Yii::$app->request->isAjax) {
//
Yii::$app->response->format = Response::FORMAT_JSON;
//
//
return ArrayHelper::merge(
//
ActiveForm::validateMultiple($modelFiles),
//
ActiveForm::validate($model)
//
);
//
}
//
//
// validate all models
//
$valid = $model->validate();
//
$valid = Model::validateMultiple($modelFiles) && $valid;
//
//
if ($valid) {
//
$transaction = \Yii::$app->db->beginTransaction();
//
try {
//
if ($flag = $model->save(false)) {
//
foreach ($modelFiles as $modelFile) {
//
$modelFile->category_id = $model->id;
//
if (!($flag = $modelFile->save(false))) {
//
$transaction->rollBack();
//
break;
//
}
//
}
//
}
//
if ($flag) {
//
$transaction->commit();
//
//
return $this->redirect(['file', 'category_id' => $model->id]);
//
}
//
} catch (Exception $e) {
//
$transaction->rollBack();
//
}
//
}
//
}
//
//
return $this->render('file', [
//
'model' => $model,
//
'modelFiles' => (empty($modelFiles)) ? [new CategoryFiles()] : $modelFiles
//
]);
//
}
}
backend/modules/theme/views/category/index.php
View file @
da370fae
...
...
@@ -27,7 +27,6 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel'
=>
$searchModel
,
'columns'
=>
[
[
'class'
=>
'yii\grid\SerialColumn'
],
// 'id',
'name'
,
// 'slug',
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment