Sep 8
逆引きrhaco55: データ削除前に確認画面を用意する
generic.ViewsのconfirmedCreate, confirmedUpdateのデータ削除版ですが、rhacoの場合同クラスのdropメソッドで確認画面用テンプレートを指定すれば自動で確認画面に移動してくれます。
やり方は下の通りです。
1. resources/templates/generic/モデル名_confirm_delete.htmlを用意する
例えばrhaco/resources/templates/generic/views/confirm.htmlをコピーしてproduct_confirm_delete.htmlという名前にし、rhaco/resources/templates/generic/views/main.htmlをresources/templates/genericにコピーする。コピーしたproduct_confirm_delete.htmlの
<form method="get">
<input type="submit" value="_('back')" />
</form>
の箇所を修正して戻ったときのurlを記述する。
コピーしない場合は自前で上のファイル名で確認画面を用意すれば良い。
2. views::dropを呼び出すソースを書く
$parser = Urls::parser(array('^drop/(\d+)/?$'=>array('method'=>'drop')),new DbUtil(Product::connection()));
$parser->write();