Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
multi checkboxes error
  • an error occured where i try to generate a multiple checkboxes using the Fieldset class, this is what i do :
    $categories = Model_Videos::get_categories() -> as_array('id', 'title');
    $attrs = array('options' => $categories, 'type' => 'checkbox');
    $rules = array( array('valid_string', array('numeric')));
    $form -> add('categories', Lang::get('categories') . ' *', $attrs, $rules);

    later in the code i call $form -> repopulate(); 

    then when i check one or more checkboxes, i got an exception error : 

    ErrorException [ Warning ]: preg_match() expects parameter 2 to be string, array given

    COREPATH/classes/validation.php @ line 890 

    it happen only when i check a checkboxe and submit the form.!!
  • HarroHarro
    Accepted Answer
    parameter 2 is the value to validate. Instead of a string, Input::post('categories') contains an array.
  • thank you, it solved.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion