⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Multiselect validation fails on v1.5.7



Kostas Botonis

Kostas Botonis
  • profile picture
  • Member

Posted 10 October 2016 - 20:48 PM

Hi there,

I have noticed that if there is a multiselect field required the validation fails. This happens on all cases (n-n relation, enum database field, field_type multiselect). Could you please guide me on a solution on this?

 

[attachment=1148:Capture.PNG]


Vitor Fonseca

Vitor Fonseca
  • profile picture
  • Member

Posted 17 March 2017 - 13:02 PM

Yes it's true!

 

Workaround:

 

$crud->required_fields('multiselect_field');    

 

$crud->set_rules('multiselect_field', 'Title', 'required|callback_check_multiselect_field');

 

...

 

    function check_multiselect_field($value){

//value outputs nothing
        $values = $this->input->post('multiselect_field');
        if (!is_array($values)){
            $this->form_validation->set_message('check_multiselect_field', 'Field mandatory');            
            return false;
        }
        return true;
    }   


Json Sean

Json Sean
  • profile picture
  • Member

Posted 14 September 2017 - 08:46 AM

Modify file of 'system/libraries/Form_validation.php':

 

in the function "public function run($group = '')",before _execute action add codes like this:

 

...

 

if(in_array('required',$row['rules']) and is_array($row['postdata'])){
$row['postdata'] = json_encode($row['postdata'],JSON_UNESCAPED_UNICODE);
}

 

...
$this->_execute($row, $row['rules'], $row['postdata']);


prattom

prattom
  • profile picture
  • Member

Posted 06 July 2018 - 13:02 PM

This is still a bug in latest version of grocery crud 1.6.1. There was no such problem in older version 1.5.1


michaelh613

michaelh613
  • profile picture
  • Member

Posted 07 August 2018 - 13:23 PM

I can confirm the error is still occurring is there any plans to fix the problem soon?  It's not mentioned in the known issues portion of the site.