0

I am trying to get the checked valueboxes to be stored in the database column named: checklist.

I am not sure how to get the array values to be converted in a valueform thats abled to be stored in mysql.

The code so far:

$checklist_options = array('test1' => 'test1', 'test2' =>'test2', 'test3' => 'test3');

echo $this->Form->select('checklist', $checklist_options, [
    'multiple' => 'checkbox'
    ]);

The rest is just the form.

  • Delimited strings are [**one of the worst datastructures there is**](https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad), the very opposite of normalization. So my first question would be whether you are 100% sure that you _must_ use it? Because if you don't have an actual technical need for such a structure, you should definitely avoid it. – ndm Mar 23 '20 at 11:51
  • I didnt know this, thanks for the information. Then i will avoid doing this. – Ninjabullen Mar 23 '20 at 12:15

1 Answers1

0

Try below code to implode the array values as colon separated or any other separator you wish.

$checklist = implode(';', $_POST['checklist']);