php - laravel 4 - Input old for arrayed checkbox -
i have loop of checkboxes multiple attributes. 1 content may have many attributes, user can check more 1 attribute.
if validation errors occurs in form need pre-fetch checked attribute.
@foreach($attributes $entry) <div class="check-line"> <input type="checkbox" id="cat4" class='icheck-me' name="attribute[<?php echo $entry->id; ?>]" data-skin="square" data-color="blue" value="{{$entry->id}}" <?php if(input::old('attribute['.$entry->id.']')== $entry->id) { echo 'checked="checked"'; } ?> /> <label class='inline' for="cat4"> <strong>{{$entry->name}}</strong> </label> </div> @endforeach
i tried above no luck.. ideas?
from laravel docs on requests:
"when working on forms "array" inputs, may utilize dot notation access arrays:"
$input = input::get('products.0.name');
so should able fpr input::old()
well:
<?php if(input::old('attribute.' . $ii) == $entry->id) { echo 'checked="checked"'; } ?>
php validation checkbox laravel laravel-4
No comments:
Post a Comment