03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Access Control List 47<br />

116 }<br />

117<br />

118 if ($type !== "hidden")<br />

119 {<br />

120 $markup .= "";<br />

121 }<br />

122<br />

123 return $markup;<br />

124 });<br />

.<br />

This file should be saved as app/macros.php.<br />

This macro evaluates an $options array, generating a label, input element and validation error<br />

message. There’s white a lot of checking involved to ensure that all the required data is there, and<br />

that optional data affects the generated markup correctly. It supports text inputs, password inputs,<br />

checkboxes and hidden fields; but more types can easily be added.<br />

.<br />

The markup this macro generates is Bootstrap friendly. If you haven’t already heard of Bootstrap<br />

(where have you been?) then you can find out more about it at: http://getbootstrap.com/<br />

To see this in action, we need to include it in the startup processes of the application and then modify<br />

the form views to use it:<br />

1 require app_path() . "/macros.php";<br />

.<br />

This was extracted from app/start/global.php.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!