質問編集履歴
2
arrayの数が違ったので修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
```
|
49
49
|
"item_group" => array:1 [▼
|
50
50
|
1 => array:1 [▼
|
51
|
-
0 => array:
|
51
|
+
0 => array:1 [▼
|
52
52
|
"item_name" => "商品名" // 例えば "チョコレート" とかが入ってきます。
|
53
53
|
]
|
54
54
|
]
|
1
コードに統一性がなかったので修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,8 +32,8 @@
|
|
32
32
|
/* 追加ボタンが押され、二つ目の商品名のフォームになると [1][item_name] / 1.item_name となっていきます。 */
|
33
33
|
{{
|
34
34
|
Form::text(
|
35
|
-
"
|
35
|
+
"item_group[$index][0][item_name]",
|
36
|
-
old('
|
36
|
+
old('item_group.' . $index . '.0.item_name') ?? '',
|
37
37
|
[
|
38
38
|
'required',
|
39
39
|
'class' => 'input-field'
|
@@ -57,8 +57,8 @@
|
|
57
57
|
|
58
58
|
### 試したこと
|
59
59
|
|
60
|
-
①該当のソースコードと同じで `old('
|
60
|
+
①該当のソースコードと同じで `old('item_group.' . $index . '.0.item_name')`
|
61
|
-
②別の方法で、 `old("
|
61
|
+
②別の方法で、 `old("item_group.$index.0.item_name")`
|
62
62
|
|
63
63
|
いずれも エラー `Undefined index: item_name` が出ます。
|
64
64
|
|
@@ -66,9 +66,9 @@
|
|
66
66
|
|
67
67
|
```Laravel
|
68
68
|
/* bladeでdd()するといずれの方法でも入力値をstringで取得できている */
|
69
|
-
@php dd(old('
|
69
|
+
@php dd(old('item_group.' . $index . '.0.item_name')); @endphp
|
70
70
|
|
71
|
-
@php dd(old("
|
71
|
+
@php dd(old("item_group.$index.0.item_name")); @endphp
|
72
72
|
```
|
73
73
|
|
74
74
|
Form内でやると失敗するのでしょうか。。。
|