Hi everyone!
Need some help with a grav error. I’m working on a gym website and I would like to create the classes schedule with 7 tabs (one for each day). In every tab there will be the classes of the selected day.
Example
Monday: yoga, pilates
Tuesday: pilates, box, karate
and so on…
So I created a class.yaml file with a list in order to add as many classes as I want. Inside the list, a Select form with Multiple enabled.
class.yaml file
header.classes:
type: list
label: Add Class
fields:
.title:
type: text
label: Name of the single class
.days:
type: select
classes: fancy
label: Days of classes
multiple: true
options:
monday: Monday
tuesday: Tuesday
wednesday: Wednesday
thursday: Thursday
friday: Friday
saturday: Saturday
sunday: sunday
On back end it shows up good, but when I’m going to save something in this form I got this error “Array to string conversion”
Error Detail
if ((!isset($params['multiline']) || !$params['multiline']) && preg_match('/\R/um', $value)) {
return false;
}
return true;
}
protected static function filterText($value, array $params, array $field)
{
return (string) $value;
}
protected static function filterCommaList($value, array $params, array $field)
{
return is_array($value) ? $value : preg_split('/\s*,\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
}
protected static function typeCommaList($value, array $params, array $field)
{
return is_array($value) ? true : self::typeText($value, $params, $field);
}
protected static function filterLower($value, array $params)
{
Am I doing something wrong? How can I prevent this to happen?
Thanks for the help!