Skip to content

Commit

Permalink
Avoid request params to use rendering HTML fc2blog#338
Browse files Browse the repository at this point in the history
  • Loading branch information
uzulla committed Aug 8, 2021
1 parent 6797280 commit f5a990a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions app/src/Web/Controller/Admin/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ public function edit(Request $request): string
$options = $categories_model->getParentList($blog_id, $id);
$this->set('category_parents', [0 => ''] + $options);
$this->set('categories_model_order_list', $categories_model::getOrderList());
$category = $categories_model->findByIdAndBlogId($id, $blog_id);
$this->set('category', $category);

// 編集対象がみつからないので、新規作成にリダイレクト
if ($category === false) {
$this->redirect($request, ['action' => 'create']);
}

// 初期表示時に編集データの取得&設定
if (!$request->get('category') || !$request->isValidSig()) {
if (!$category = $categories_model->findByIdAndBlogId($id, $blog_id)) {
$this->redirect($request, ['action' => 'create']);
}
$request->set('category', $category);
return "admin/categories/edit.twig";
}
Expand Down
2 changes: 1 addition & 1 deletion app/twig_templates/admin/categories/edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<form action="edit" method="post" class="admin-form">

<input type="hidden" name="id" value="{{ req.get('id') }}"/>
<input type="hidden" name="id" value="{{ category.id }}"/>
<input type="hidden" name="sig" value="{{ sig }}"/>

<table>
Expand Down
2 changes: 1 addition & 1 deletion app/twig_templates/admin/categories/edit_sp.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<h2><span class="h2_inner">{{ _('Edit category') }}</span></h2>
<form action="edit" method="post" class="admin-form">
<input type="hidden" name="id" value="{{ req.get('id') }}"/>
<input type="hidden" name="id" value="{{ category.id }}"/>
<input type="hidden" name="sig" value="{{ sig }}"/>
<div class="form_area">
<div class="form_contents">
Expand Down

0 comments on commit f5a990a

Please sign in to comment.