私は検証エラーがなければ私の編集アクションはうまくいきます。バリデーションエラーの後、フォームアクションがポストIDを失う - CakePHP
検証エラーが見つかると、ビューはエラーメッセージとともに再度レンダリングされますが、フォームタグのアクション内のURLは投稿IDを失います。
検証エラーの前に
:検証エラーの後
<form class="niceInput" id="PostEditForm" method="post" action="/posts/edit/1" accept-charset="utf-8">
:これを引き起こしている可能性が何
<form class="niceInput" id="PostEditForm" method="post" action="/posts/edit" accept-charset="utf-8">
?
おかげ
EDIT:あなたはする必要がありadd.ctpビュー
if ($this->action == 'edit') {
echo $this->Form->create('Post', array('class' => 'niceInput', 'action' => 'edit'));
} else {
echo $this->Form->create('Post', array('class' => 'niceInput'));
}
echo $this->Form->input('type', array(
'label' => 'Type of post',
'type' => 'select',
'options' => array(
'rent' => 'Rental',
'roommate' => 'Roommate',
'sublet' => 'Sublet'
)));
echo $this->Form->input('street_address', array('label' => 'Street address'));
echo $this->Form->input('city');
echo $this->Form->input('province');
echo $this->Form->input('price');
echo $this->Form->input('bedrooms');
echo $this->Form->input('bathrooms');
echo $this->Form->input('utilities', array('label' => 'Utilities Included'));
echo $this->Form->input('washer_dryer');
echo $this->Form->input('dishwasher');
echo $this->Form->input('a_c');
echo $this->Form->input('parking_spots');
echo $this->Form->hidden('image_files');
echo $this->Form->input('description');
if ($this->action == 'edit') {
$buttonLabel = 'Save changes';
} else {
$buttonLabel = 'Add house';
}
echo $this->Form->button($buttonLabel, array('id' => 'addButton'));
echo $this->Form->end();
'edit'メソッドコードを投稿できますか? – Ross
投稿、ありがとう! – AlexBrand