質問編集履歴

9

追記

2018/03/26 12:51

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -343,3 +343,69 @@
343
343
  }
344
344
 
345
345
  ```
346
+
347
+ ##controller追記
348
+
349
+ エラー内容
350
+
351
+ ```php
352
+
353
+ //1つめ
354
+
355
+ Twig_Error_Runtime in Template.php line 230:
356
+
357
+ An exception has been thrown during the rendering of a template ("User Warning: Unable to generate a URL for the named route "plugin_CategoryContent_config" as such route does not exist.") in "__string_template__283ef8214125d3fcd7d25d73043851d03dcdefbc05ff095ca850bb1d87f8358f" at line 11.
358
+
359
+
360
+
361
+ //2つめ
362
+
363
+ ContextErrorException in EccubeExtension.php line 172:
364
+
365
+ User Warning: Unable to generate a URL for the named route "plugin_CategoryContent_config" as such route does not exist.
366
+
367
+ ```
368
+
369
+
370
+
371
+ controller
372
+
373
+ ```php
374
+
375
+ public function index(Application $app, Request $request)
376
+
377
+ {
378
+
379
+
380
+
381
+ $form = $app['form.factory']
382
+
383
+ ->createBuilder('categorycontent')
384
+
385
+ ->getForm();
386
+
387
+
388
+
389
+ $form->handleRequest($request);
390
+
391
+
392
+
393
+ if ($form->isSubmitted() && $form->isValid()) {
394
+
395
+ $data = $form->getData();
396
+
397
+
398
+
399
+
400
+
401
+ }
402
+
403
+ return $app->render('CategoryContent/Resource/template/admin/config.twig', array(
404
+
405
+ 'form' => $form->createView(),
406
+
407
+ ));
408
+
409
+ }
410
+
411
+ ```

8

修正

2018/03/26 12:51

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- EC-CUBE3のプラグインオリジナル項目追加、フォムを追加したいです
3
+ EC-CUBE3のプラグインオリジナルメニュの表示
4
4
 
5
5
 
6
6
 

7

追加

2018/03/26 11:02

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -88,9 +88,21 @@
88
88
 
89
89
  {
90
90
 
91
-
91
+     $form->handleRequest($request);
92
+
92
-
93
+     if ($form->isSubmitted() && $form->isValid()) {
94
+
95
+     $data = $form->getData();
96
+
97
+     }
98
+
93
- return $app->render('CategoryContent/Resource/template/admin/config.twig');
99
+     return $app->render('CategoryContent/Resource/template/admin/config.twig', array(
100
+
101
+     'form' => $form->createView(),
102
+
103
+     ));
104
+
105
+
94
106
 
95
107
  }
96
108
 
@@ -281,3 +293,53 @@
281
293
  }
282
294
 
283
295
  ```
296
+
297
+
298
+
299
+ ##controller変更後
300
+
301
+ エラー
302
+
303
+ ```php
304
+
305
+
306
+
307
+ ContextErrorException in CategoryContentController.php line 30:
308
+
309
+ Notice: Undefined variable: form
310
+
311
+ ```
312
+
313
+
314
+
315
+ controller
316
+
317
+ ```php
318
+
319
+ public function index(Application $app, Request $request)
320
+
321
+ {
322
+
323
+ $form->handleRequest($request);
324
+
325
+
326
+
327
+ if ($form->isSubmitted() && $form->isValid()) {
328
+
329
+ $data = $form->getData();
330
+
331
+
332
+
333
+
334
+
335
+ }
336
+
337
+ return $app->render('CategoryContent/Resource/template/admin/config.twig', array(
338
+
339
+ 'form' => $form->createView(),
340
+
341
+ ));
342
+
343
+ }
344
+
345
+ ```

6

修正

2018/03/26 09:29

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -204,6 +204,10 @@
204
204
 
205
205
  フォーム
206
206
 
207
+ CategoryContentConfigType.php
208
+
209
+ ```php
210
+
207
211
  class CategoryContentConfigType extends AbstractType
208
212
 
209
213
  {

5

再度修正

2018/03/26 08:28

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -204,86 +204,76 @@
204
204
 
205
205
  フォーム
206
206
 
207
- CategoryContentConfigType.php
208
-
209
- ```php
210
-
211
- {% extends 'default_frame.twig' %}
212
-
213
-
214
-
215
- {% set menus = ['store', 'plugin', 'plugin_list'] %}
216
-
217
-
218
-
219
- {% block title %}CategoryContent画面{% endblock %}
220
-
221
- {% block sub_title %}CategoryContent設定{% endblock %}
222
-
223
-
224
-
225
- {% form_theme form 'Form/bootstrap_3_horizontal_layout.html.twig' %}
226
-
227
-
228
-
229
- {% block main %}
230
-
231
- <form class="form-horizontal" method="post" action="{{ url('plugin_CategoryContent_config') }}">
232
-
233
- {{ form_widget(form._token) }}
234
-
235
- <div class="row" id="aside_wrap">
236
-
237
- <div class="col-md-9">
238
-
239
- <div class="box">
240
-
241
- <div class="box-header">
242
-
243
- <h3 class="box-title">CategoryContent設定</h3>
244
-
245
- </div><!-- /.box-header -->
246
-
247
- <div class="box-body form-horizontal">
248
-
249
- {{ form_row(form.name) }}
250
-
251
- </div><!-- /.box-body -->
252
-
253
- </div><!-- /.box -->
254
-
255
- </div><!-- /.col -->
256
-
257
- <div class="col-md-3" id="aside_column">
258
-
259
- <div id="common_box" class="col_inner">
260
-
261
- <div id="common_button_box" class="box no-header">
262
-
263
- <div id="common_button_box__body" class="box-body">
264
-
265
- <div id="common_button_box__edit_button" class="row text-center">
266
-
267
- <div class="col-sm-6 col-sm-offset-3 col-md-12 col-md-offset-0">
268
-
269
- <button class="btn btn-primary btn-block btn-lg" type="submit">設定</button>
270
-
271
- </div>
272
-
273
- </div>
274
-
275
- </div><!-- /.box-body -->
276
-
277
- </div><!-- /.box -->
278
-
279
- </div>
280
-
281
- </div><!-- /.col -->
282
-
283
- </div>
284
-
285
- </form>
286
-
287
- {% endblock main %}
288
-
289
- ```
207
+ class CategoryContentConfigType extends AbstractType
208
+
209
+ {
210
+
211
+ public function buildForm(FormBuilderInterface $builder, array $options)
212
+
213
+ {
214
+
215
+
216
+
217
+ $builder
218
+
219
+ ->add(
220
+
221
+ 'name',
222
+
223
+ 'text',
224
+
225
+ array(
226
+
227
+ 'constraints' => array(
228
+
229
+ new Assert\NotBlank(),
230
+
231
+ ),
232
+
233
+ )
234
+
235
+ )
236
+
237
+ ->add(
238
+
239
+ 'code',
240
+
241
+ 'text',
242
+
243
+ array(
244
+
245
+ 'constraints' => array(
246
+
247
+ new Assert\NotBlank(),
248
+
249
+ ),
250
+
251
+ )
252
+
253
+ );
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ }
262
+
263
+
264
+
265
+ public function getName()
266
+
267
+ {
268
+
269
+ return 'categorycontent';
270
+
271
+ }
272
+
273
+
274
+
275
+
276
+
277
+ }
278
+
279
+ ```

4

修正

2018/03/26 08:27

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -202,9 +202,9 @@
202
202
 
203
203
  ```
204
204
 
205
-
205
+ フォーム
206
-
206
+
207
- form.php
207
+ CategoryContentConfigType.php
208
208
 
209
209
  ```php
210
210
 

3

修正

2018/03/26 08:25

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -200,6 +200,8 @@
200
200
 
201
201
  {% endblock main %}
202
202
 
203
+ ```
204
+
203
205
 
204
206
 
205
207
  form.php
@@ -285,7 +287,3 @@
285
287
  {% endblock main %}
286
288
 
287
289
  ```
288
-
289
-
290
-
291
- ```

2

ソース追加

2018/03/26 08:25

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -200,4 +200,92 @@
200
200
 
201
201
  {% endblock main %}
202
202
 
203
+
204
+
205
+ form.php
206
+
207
+ ```php
208
+
209
+ {% extends 'default_frame.twig' %}
210
+
211
+
212
+
213
+ {% set menus = ['store', 'plugin', 'plugin_list'] %}
214
+
215
+
216
+
217
+ {% block title %}CategoryContent画面{% endblock %}
218
+
219
+ {% block sub_title %}CategoryContent設定{% endblock %}
220
+
221
+
222
+
223
+ {% form_theme form 'Form/bootstrap_3_horizontal_layout.html.twig' %}
224
+
225
+
226
+
227
+ {% block main %}
228
+
229
+ <form class="form-horizontal" method="post" action="{{ url('plugin_CategoryContent_config') }}">
230
+
231
+ {{ form_widget(form._token) }}
232
+
233
+ <div class="row" id="aside_wrap">
234
+
235
+ <div class="col-md-9">
236
+
237
+ <div class="box">
238
+
239
+ <div class="box-header">
240
+
241
+ <h3 class="box-title">CategoryContent設定</h3>
242
+
243
+ </div><!-- /.box-header -->
244
+
245
+ <div class="box-body form-horizontal">
246
+
247
+ {{ form_row(form.name) }}
248
+
249
+ </div><!-- /.box-body -->
250
+
251
+ </div><!-- /.box -->
252
+
253
+ </div><!-- /.col -->
254
+
255
+ <div class="col-md-3" id="aside_column">
256
+
257
+ <div id="common_box" class="col_inner">
258
+
259
+ <div id="common_button_box" class="box no-header">
260
+
261
+ <div id="common_button_box__body" class="box-body">
262
+
263
+ <div id="common_button_box__edit_button" class="row text-center">
264
+
265
+ <div class="col-sm-6 col-sm-offset-3 col-md-12 col-md-offset-0">
266
+
267
+ <button class="btn btn-primary btn-block btn-lg" type="submit">設定</button>
268
+
269
+ </div>
270
+
271
+ </div>
272
+
273
+ </div><!-- /.box-body -->
274
+
275
+ </div><!-- /.box -->
276
+
277
+ </div>
278
+
279
+ </div><!-- /.col -->
280
+
281
+ </div>
282
+
283
+ </form>
284
+
285
+ {% endblock main %}
286
+
203
- ```
287
+ ```
288
+
289
+
290
+
291
+ ```

1

ソース追加

2018/03/26 08:23

投稿

poipo
poipo

スコア13

test CHANGED
File without changes
test CHANGED
@@ -111,3 +111,93 @@
111
111
 
112
112
 
113
113
  ご教示いただければと思います。何卒よろしくお願いいたします。
114
+
115
+
116
+
117
+
118
+
119
+ ###追加
120
+
121
+ config.twig
122
+
123
+ ```php
124
+
125
+ {% extends 'default_frame.twig' %}
126
+
127
+
128
+
129
+ {% set menus = ['store', 'plugin', 'plugin_list'] %}
130
+
131
+
132
+
133
+ {% block title %}CategoryContent画面{% endblock %}
134
+
135
+ {% block sub_title %}CategoryContent設定{% endblock %}
136
+
137
+
138
+
139
+ {% form_theme form 'Form/bootstrap_3_horizontal_layout.html.twig' %}
140
+
141
+
142
+
143
+ {% block main %}
144
+
145
+ <form class="form-horizontal" method="post" action="{{ url('plugin_CategoryContent_config') }}">
146
+
147
+ {{ form_widget(form._token) }}
148
+
149
+ <div class="row" id="aside_wrap">
150
+
151
+ <div class="col-md-9">
152
+
153
+ <div class="box">
154
+
155
+ <div class="box-header">
156
+
157
+ <h3 class="box-title">CategoryContent設定</h3>
158
+
159
+ </div><!-- /.box-header -->
160
+
161
+ <div class="box-body form-horizontal">
162
+
163
+ {{ form_row(form.name) }}
164
+
165
+ </div><!-- /.box-body -->
166
+
167
+ </div><!-- /.box -->
168
+
169
+ </div><!-- /.col -->
170
+
171
+ <div class="col-md-3" id="aside_column">
172
+
173
+ <div id="common_box" class="col_inner">
174
+
175
+ <div id="common_button_box" class="box no-header">
176
+
177
+ <div id="common_button_box__body" class="box-body">
178
+
179
+ <div id="common_button_box__edit_button" class="row text-center">
180
+
181
+ <div class="col-sm-6 col-sm-offset-3 col-md-12 col-md-offset-0">
182
+
183
+ <button class="btn btn-primary btn-block btn-lg" type="submit">設定</button>
184
+
185
+ </div>
186
+
187
+ </div>
188
+
189
+ </div><!-- /.box-body -->
190
+
191
+ </div><!-- /.box -->
192
+
193
+ </div>
194
+
195
+ </div><!-- /.col -->
196
+
197
+ </div>
198
+
199
+ </form>
200
+
201
+ {% endblock main %}
202
+
203
+ ```