/** * Called to map the submitted data into the field. * Typically this is called when a form is submitted to set up all the fields * with the values entered by the user, ready for validation * @param $data */ public function bind($data) { // when multi-select items are set, we sometimes need to remap the data a little if (is_array($data)) { // remap the data $data = array_values($data); } // If nothing is selected, then we can end up with a null input here // change it to an empty array for consistency if ($data == null) { $data = array(); } // finally, set the value like normal parent::bind($data); }