I'm Using Laravel 4 to make an application. There is a form to create an event, which is then processed in the Controller.
This is my code for the checkboxes:
@foreach($value['value'][$i] as $key1=>$value1)
{{ Form::checkbox('amenities[]', $value1) }}
@endforeach
I have a function in my Controller, which has this code:
$amenitiesALL = array();
$amenitiesALL = Input::get('amenities');
foreach($amenitiesALL as $amenities)
{
$amenity = new EventAmenities;
$amenity::create(array('EVENT_ID' => $eventID, 'EVENT_AMENITIES_ID' => $amenities));
}
It's raising an error every time
[2014-06-29 13:55:46] production.ERROR: exception 'ErrorException' with message 'preg_replace(): Parameter mismatch, pattern is a string while replacement is an array' in E:\wamp\www\bt\vendor\laravel\framework\src\Illuminate\Support\helpers.php:973
How do I make the variable take the input from the form as an array? Any other suggestions would also help.
app/storage/logs/laravel.logwould also help. I don't know why it's trying to callpreg_replace().Model::create()doesn't seem to need a preg_replace.$amenities = ''.$ameneties.'';And then it worked!var_dump($ameneties)as well.