lundi 20 juillet 2015

How to store multiple checkbox values in one field?

How can I store these four values in one field as array?

Below is my code. Am getting error like "preg_replace(): Parameter mismatch, pattern is a string while replacement is an array".

And also how can I retrieve the stored checkbox value?

Could anyone help me? Thanks in advance.

Controller code:

In store function, I've written this.

$data = Facility::create(Request::all());
            $claimtype = Input::get('claim_type');
                if(is_array($claimtype))
                {
                $claimtype = implode(',', $claimtype);

                }

            $data->claim_type = $claimtype ;
            $data->save();

View code:

 {!! Form::checkbox('claim_type[]', '1') !!} Professional 
                {!! Form::checkbox('claim_type[]', '2') !!} Dental 
                {!! Form::checkbox('claim_type[]', '3') !!} Institutional 
                {!! Form::checkbox('claim_type[]', '4') !!} DME




Aucun commentaire:

Enregistrer un commentaire