html - Radio and checkbox inside label with Laravel -
is there way utilize form::label checkboxes , radio inputs generate markup bootstrap suggests? aim have input fields within labels instead of attaching them ids. avoid hardcoding markup around form::radio
<div class="checkbox"> <label> <input type="checkbox" value=""> alternative 1 , that—be sure include why it's great </label> </div> <div class="radio"> <label> <input type="radio" name="optionsradios" id="optionsradios1" value="option1" checked> alternative 1 , that—be sure include why it's great </label> </div> <div class="radio"> <label> <input type="radio" name="optionsradios" id="optionsradios2" value="option2"> alternative 2 can else , selecting deselect alternative 1 </label> </div>
you can write own form macro , utilize build html like.
http://laravel.com/docs/4.2/html#custom-macros
something like:
form::macro('bootcheckbox', function($value, $label) { $html = '<div class="checkbox"><label><input type="checkbox" value="'; $html .= $value; $html .= '">'; $html .= $label; $html .= '</label></div>' homecoming $html } and can phone call in view:
{{ form::bootcheck('i_dont_know_what_value_youd_like', 'option 1 , that—be sure include why it's great') }}
of course of study can pass value macro , build whatever want (given code on macro side sound). illustration above here should output checkbox showed, it's not clean , haven't tested it.
as set code, can set anywhere long link it. form macro's (which bit more extensive) live in /app/start/form_macros.php , required in /app/start/global.php adding require dirname(__file__) . '/form_macros.php'; end of it.
html twitter-bootstrap laravel
No comments:
Post a Comment