stevenmaguire/zurb-foundation-laravel — pull request #8 by esolitos (2014-06-17 23:04:06+00:00)
Title: Foundation 5 Adaptation &co.

Hi, I made some improvements to this nice package. Mostly with the idea to port it to Foundation 5.

Those are the changes:
- Added the new ``withLabel($name, $label)`` that allows to define a label for a
form item.
- Label that are added using this new method will wrap around the element as suggested
by Foundation 5 [http://foundation.zurb.com/docs/components/forms.html]
- Checkboxes and Radio that are going to use this new method will have a specific
ID so the labels can be correctly clicked to check the input item.
- Tests have been improved using ``assertTag()`` instead of an intricate and unsafe
``assertTrue()`` using ``strpos``.

Taking the README example for the *Usage* chapter here's how it simplifies:
```html

{{ Form::model($user,array('route' => 'route.name','class' => 'custom')) }}

Create New Account

{{ Form::withLabel('name', "Full Name")->text('name',$user->name,array('placeholder'=>'Tell us your whole name')) }}
{{ Form::withLabel('email', 'Email')->text('email',$user->email,array('placeholder'=>'Valid email used to login and receive information from us')) }}
{{ Form::withLabel('password', 'Password')->password('password',$user->password,array('placeholder'=>'Gimme your password')) }}
{{ Form::submit('Create Account',array('class'=>'button')) }}

{{ Form::close() }}

```
will render without errors

```html

Create New Account

Full Name
Email
Password

```

and in case of errors a ``$error_message `` will be added inside the label and the class ``error`` will be applied to both the ```` and the ``input/select/textarea/...``.

The method ``withLabel()`` can also be used to define all the labels like:
```php
Form::withLabel('name', 'Your Name')->withLabel('password', 'Password')-withLabel('email', 'The eMail');
```
and I'm planning to allow to accept an associative array as parameter or to add a ``defineLabels()`` method to define all the labels at once (but i'm not not sure how to manage checkboxes).
Let me know what do you think about it.
In case you don't want to merge I'll make a separate package keeping you in the credits as original author.

*Note: If you look at the full diff of ``FormBuilder`` it is "complex" to understand, look at the single commits and the steps are going to be more clear.*

PS: This is the laravel view I use for testing the output:
```html

foundation-form.blade

{{ Form::open(['url' => 'route.name','class' => 'custom']) }}

Just a Fieldset

{{ Form::withLabel('name', "Your full Name")->text('name', "MyUsername", ['placeholder'=>'Tell us your whole name'] ) }}
{{ Form::label('another_name') }}
{{ Form::text('another_name', "MyUsername", ['placeholder'=>'Tell us your whole name'] ) }}
{{ Form::withLabel('an_email', "Email")->email('an_email', "email@example.com") }}
{{ Form::withLabel('your_password', 'Password')->password('your_password', ['placeholder'=>'Gimme your password'] ) }}
{{ Form::withLabel('long_text', 'Long Text?')->textarea('long_text', "Something written down", ['placeholder'=>'Gimme your password'] ) }}
{{ Form::withLabel('some_month', 'Select a Month')->selectMonth('some_month', 2) }}
{{ Form::withLabel('choose_one', 'Select Something')->select('choose_one', ["First", "Second", "Third", 'Last'], 2) }}

{{ Form::label('choose', "Two Options") }}
{{ Form::withLabel('choose', 'Red')->checkbox('choose', 1, TRUE) }}
{{ Form::withLabel('choose', 'Yellow')->checkbox('choose', 2, FALSE) }}

{{ Form::label('check', "Other Checkboxes") }}
{{ Form::withLabel('check', 'Box')->checkbox('check', 'box', FALSE) }}
{{ Form::withLabel('check', 'Cartboard')->checkbox('check', 'board', FALSE) }}
{{ Form::withLabel('check', 'Paper')->checkbox('check', 'paper', FALSE) }}

{{ Form::label('qty', "Radio Selection") }}
{{ Form::withLabel('qty', 'Full')->radio('qty', '1', FALSE) }}
{{ Form::withLabel('qty', 'Half Full')->radio('qty', '0.5', FALSE, ['id'=>'half-full']) }}
{{ Form::withLabel('qty', 'Half Empty')->radio('qty', '0.5', FALSE, ['id'=>'half-empty']) }}
{{ Form::withLabel('qty', 'Empty')->radio('qty', '0', FALSE) }}

{{ Form::submit('Create Account',array('class'=>'button')) }}

{{ Form::close() }}

```