laravel/framework — pull request #2036 by Ruby184 (2013-08-05 17:56:06+00:00)
Title: Fix form populating with array names

PHP uses `[]` syntax to interpret the input as an array an not as a single value. Currently if such a name is used with input names, it is used as is without converting it to real key. As a result form is not repopulated with old input.

This PR fixes:

- Issues https://github.com/laravel/framework/issues/2033, https://github.com/laravel/framework/issues/2010

- repopulating form input with array syntax, converting it's name to dot syntax. Also fixed dots in names (PHP will automatically replace any dots in incoming variable names with underscores, see http://www.php.net/manual/en/language.variables.external.php). This ensures that old value is always found if it exists.
name[] => name
name[key] => name.key
name[key][] => name.key
name.key => name_key

- converting to dot syntax has another advantage, it cans be used to polulate form with attribute of model relation. I'have found out that `__isset` method on Eloquent for dynamic checking if an attribute exists is broken with relations. It returns false for relations which weren't accessed before.

```php
$post = Post::find(1);

isset($post->author); // false
$post->author;
isset($post->author); // true
```
So I changed condition to:

```php
return ! is_null($this->getAttribute($key));
```
Now it is possible to do:

```
{{ Form::model($model) }}
.
.
.
{{ Form::text('author[name]') }} // Automatically populate input with 'name' attribute from 'author' relation on model

```

- checking checkboxes with array name. So now checkboxes like the following one are properly checked

```
{{ Form::checkbox('checkbox[]', 1) }}
{{ Form::checkbox('checkbox[]', 2) }}
```

Best regards, Ruby.