Laravel使ってみた (13) - Forms & HTML -
http://laravel.com/docs/html を読みつつやってみるだけ
- Form::open -> <form>
- Form::close -> </form>
- Form::token -> <input type=
hidden
name=_token
value=...
/> - Form::label -> <label for=""></label>
- Form::input -> <input type=
...
/> - Form::text -> <input type=
text
/> - Form::password -> <input type=
password
/> - Form::hidden -> <input type=
hidden
/> - Form::email -> <input type=
email
/> - Form::file -> <input type=
file
/> - Form::textarea -> <textarea>
- Form::select -> <select>
- Form::option -> <option>
- Form::checkbox -> <input type=
checkbox
/> - Form::radio -> <input type=
radio
/> - Form::reset -> <input type=
reset
/> - Form::image -> <input type=
image
/> - Form::submit -> <input type=
submit
/ - Form::button -> <button type=
button
></button>
的なのが出力される。でこのAPIはmacroメソッドで拡張できる
<?php
Form::macro("hr", function() {
return "<hr>";
});
っていう感じで定義しとけば良い。んまぁForm::hrとか定義するのは間違ってるけど
でこいつのFormクラス自体は Illuminate\Html\FormBuilderになってるけど、 Illuminate\Html\HtmlBuilderっていうのもある。ビューとかでHTMLクラス(Htmlではない。uppercaseに注意)を使う事でメソッドとかを利用できる
CSRF Protectionセクションに関しては前回で書いてるので(ry