質問編集履歴

1

該当コードの追加

2021/10/04 08:46

投稿

Y0shito
Y0shito

スコア3

test CHANGED
File without changes
test CHANGED
@@ -69,3 +69,65 @@
69
69
  エラー内容の確認とformのname周りやタイポなど見ていますが、原因がつかめません。
70
70
 
71
71
  解決するにはどうすればいいでしょうか?
72
+
73
+
74
+
75
+ 追記:記事の表示部分を掲載し直しました。
76
+
77
+ また掲載して気づいたのですが、@foreach内にformを入れているため、form name="articleOptions"が繰り返し生成されていました。これが悪さをしているのでしょうか?
78
+
79
+ ```HTML
80
+
81
+ @foreach ($items as $item)
82
+
83
+ <div class="card my-3">
84
+
85
+ <div class="card-header d-inline-flex pb-0">
86
+
87
+ <h3><a href="article/id/{{ $item->id }}">{{ $item->title }}</a></h3>
88
+
89
+ <div class="ml-auto d-inline-flex">
90
+
91
+ <form name="articleOptions" method="POST">
92
+
93
+ @csrf
94
+
95
+
96
+
97
+ @if ($item->open == \App\Enums\PublicStatus::OPEN) //記事が公開されていれば非公開ボタン
98
+
99
+ <button class="btn btn-secondary btn-sm" formaction="close" name="id"
100
+
101
+ value="{{ $item->id }}">非公開にする</button>
102
+
103
+ @else
104
+
105
+ <button class="btn btn-success btn-sm" formaction="open" name="id"
106
+
107
+ value="{{ $item->id }}">公開する</button>
108
+
109
+ @endif
110
+
111
+
112
+
113
+ <button class="btn btn-primary btn-sm" formaction="edit" name="id"
114
+
115
+ value="{{ $item->id }}">編集</button>
116
+
117
+
118
+
119
+ <button class="btn btn-danger btn-sm" onclick="articleDelete(); return false;" formaction="delete"
120
+
121
+ name="id" value="{{ $item->id }}">削除</button>
122
+
123
+ </form>
124
+
125
+ </div>
126
+
127
+ </div>
128
+
129
+ </div>
130
+
131
+ @endforeach
132
+
133
+ ```