質問編集履歴
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,3 +13,309 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
同じ画面に検索と投稿という同一のモデルに対してformがあることが原因なんでしょうか。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
<add.ctp>
|
22
|
+
|
23
|
+
<div class = "container">
|
24
|
+
|
25
|
+
<div class = "row">
|
26
|
+
|
27
|
+
<h2 class = "col-md-8 col-md-offset-2">投稿</h2>
|
28
|
+
|
29
|
+
<div class = "col-md-8 col-md-offset-2">
|
30
|
+
|
31
|
+
<?php echo $this->Form->create('Post', array(
|
32
|
+
|
33
|
+
'inputDefaults' => array(
|
34
|
+
|
35
|
+
'div' => 'form-group',
|
36
|
+
|
37
|
+
'label' => array(
|
38
|
+
|
39
|
+
'class' => 'col col-md-3 control-label'
|
40
|
+
|
41
|
+
),
|
42
|
+
|
43
|
+
'wrapInput' => 'col col-md-9',
|
44
|
+
|
45
|
+
'class' => 'form-control'
|
46
|
+
|
47
|
+
),
|
48
|
+
|
49
|
+
'class' => 'well form-horizontal'
|
50
|
+
|
51
|
+
)); ?>
|
52
|
+
|
53
|
+
<?php echo $this->Form->hidden('user_id', array('value'=>$user_info['id']));?>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<?php echo $this->Form->input('title', array(
|
58
|
+
|
59
|
+
'placeholder' => 'タイトル'
|
60
|
+
|
61
|
+
)); ?>
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<?php echo $this->Form->input('mv_id', array(
|
66
|
+
|
67
|
+
'placeholder' => '動画のID',
|
68
|
+
|
69
|
+
'type' => 'text'
|
70
|
+
|
71
|
+
)); ?>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<?php echo $this->Form->input('comment', array(
|
76
|
+
|
77
|
+
'placeholder' => 'コメント',
|
78
|
+
|
79
|
+
'rows'=>3
|
80
|
+
|
81
|
+
)); ?>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<div class="form-group">
|
86
|
+
|
87
|
+
<?php echo $this->Form->submit('投稿', array(
|
88
|
+
|
89
|
+
'div' => 'col col-md-9 col-md-offset-3',
|
90
|
+
|
91
|
+
'class' => 'btn btn-primary'
|
92
|
+
|
93
|
+
)); ?>
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<?php echo $this->Form->end(); ?>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<PostsController>
|
114
|
+
|
115
|
+
<?php
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
class PostsController extends AppController {
|
120
|
+
|
121
|
+
public function result() {
|
122
|
+
|
123
|
+
// 検索条件設定
|
124
|
+
|
125
|
+
$this->Prg->commonProcess();
|
126
|
+
|
127
|
+
if (isset($this->passedArgs['search_word'])) {
|
128
|
+
|
129
|
+
//条件を生成
|
130
|
+
|
131
|
+
//debug($this->passedArgs);
|
132
|
+
|
133
|
+
$conditions = $this->Post->parseCriteria($this->passedArgs);
|
134
|
+
|
135
|
+
$this->paginate = array(
|
136
|
+
|
137
|
+
'conditions' => $conditions,
|
138
|
+
|
139
|
+
'limit' => 3,
|
140
|
+
|
141
|
+
'order' => array(
|
142
|
+
|
143
|
+
'id' => 'desc'
|
144
|
+
|
145
|
+
)
|
146
|
+
|
147
|
+
);
|
148
|
+
|
149
|
+
$this->set('posts', $this->paginate('Post'));
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
----
|
156
|
+
|
157
|
+
public function add() {
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
if ($this->request->is('post')) {
|
162
|
+
|
163
|
+
if ($this->Post->save($this->request->data)) {
|
164
|
+
|
165
|
+
$this->Session->setFlash('Success!');
|
166
|
+
|
167
|
+
$this->redirect(array('action'=>'index'));
|
168
|
+
|
169
|
+
} else {
|
170
|
+
|
171
|
+
$this->Session->setFlash('failed!');
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<default.ctp>
|
182
|
+
|
183
|
+
<body>
|
184
|
+
|
185
|
+
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
186
|
+
|
187
|
+
<div class="container">
|
188
|
+
|
189
|
+
<div class="navbar-header">
|
190
|
+
|
191
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
|
192
|
+
|
193
|
+
<span class="sr-only">Toggle navigation</span>
|
194
|
+
|
195
|
+
<span class="icon-bar"></span>
|
196
|
+
|
197
|
+
<span class="icon-bar"></span>
|
198
|
+
|
199
|
+
<span class="icon-bar"></span>
|
200
|
+
|
201
|
+
</button>
|
202
|
+
|
203
|
+
<?php echo $this->Html->link('XXXX', array(
|
204
|
+
|
205
|
+
'controller' => 'posts',
|
206
|
+
|
207
|
+
'action' => 'index'
|
208
|
+
|
209
|
+
), array('class' => 'navbar-brand')); ?>
|
210
|
+
|
211
|
+
</div>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<div class="collapse navbar-collapse navbar-ex1-collapse">
|
216
|
+
|
217
|
+
<ul class="nav navbar-nav">
|
218
|
+
|
219
|
+
<li><?php echo $this->Html->link('Login', array(
|
220
|
+
|
221
|
+
'controller' => 'users',
|
222
|
+
|
223
|
+
'action' => 'login'
|
224
|
+
|
225
|
+
)); ?></li>
|
226
|
+
|
227
|
+
<li><?php echo $this->Html->link('SignUp', array(
|
228
|
+
|
229
|
+
'controller' => 'users',
|
230
|
+
|
231
|
+
'action' => 'register'
|
232
|
+
|
233
|
+
)); ?></li>
|
234
|
+
|
235
|
+
<li><?php echo $this->Html->link('Logout', array(
|
236
|
+
|
237
|
+
'controller' => 'users',
|
238
|
+
|
239
|
+
'action' => 'logout'
|
240
|
+
|
241
|
+
)); ?></li>
|
242
|
+
|
243
|
+
<li><?php echo $this->Html->link('Add', array(
|
244
|
+
|
245
|
+
'controller' => 'posts',
|
246
|
+
|
247
|
+
'action' => 'add'
|
248
|
+
|
249
|
+
)); ?></li>
|
250
|
+
|
251
|
+
<li><?php echo $this->Html->link($user_info['username'], array(
|
252
|
+
|
253
|
+
'controller' => 'users',
|
254
|
+
|
255
|
+
'action' => 'view'
|
256
|
+
|
257
|
+
)); ?></li>
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
<li>
|
262
|
+
|
263
|
+
<?php
|
264
|
+
|
265
|
+
echo $this->Form->create('Post', array('action' => 'result',
|
266
|
+
|
267
|
+
'type' => 'post',
|
268
|
+
|
269
|
+
'class' => 'navbar-form pull-left',
|
270
|
+
|
271
|
+
'inputDefaults' => array(
|
272
|
+
|
273
|
+
'div' => 'form-group',
|
274
|
+
|
275
|
+
'label' => false,
|
276
|
+
|
277
|
+
'wrapInput' => false,
|
278
|
+
|
279
|
+
'class' => 'form-control'
|
280
|
+
|
281
|
+
),
|
282
|
+
|
283
|
+
));?>
|
284
|
+
|
285
|
+
<?php echo $this->Form->input('search_word', array(
|
286
|
+
|
287
|
+
'placeholder' => 'Search',
|
288
|
+
|
289
|
+
'class' => 'form-inline text-left',
|
290
|
+
|
291
|
+
'after' => '<span class="glyphicon glyphicon-search"></span>',
|
292
|
+
|
293
|
+
));?>
|
294
|
+
|
295
|
+
<div class="form-group">
|
296
|
+
|
297
|
+
<?php echo $this->Form->submit('検索', array(
|
298
|
+
|
299
|
+
'div' => 'col col-md-9 col-md-offset-3',
|
300
|
+
|
301
|
+
'class' => 'btn btn-primary'
|
302
|
+
|
303
|
+
));?>
|
304
|
+
|
305
|
+
</div>
|
306
|
+
|
307
|
+
</li>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
</ul>
|
312
|
+
|
313
|
+
</div>
|
314
|
+
|
315
|
+
</div>
|
316
|
+
|
317
|
+
</nav>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<div class="container">
|
1
記載追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,3 +9,7 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
ちなみにserchのformはdefault.ctpに記載しており、ナビバーとして表示されており、add.ctp画面でも表示されています。それが関係しているような気がしているのですが、そこで詰まってしまっています。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
同じ画面に検索と投稿という同一のモデルに対してformがあることが原因なんでしょうか。
|