Validationでエラーが出たら
FuelPHPで以下のエラーが出た場合の対処法。
RuntimeException [ Error ]:
Object class "Fuel\Core\Validation" could not be converted to string or sanitized
asArrayAccess. Whitelist it in security.whitelisted_classes in app/config/config.php t
o allow it to be passed unchecked.
COREPATH/classes/security.php @ line 268
// Throw exception when
it wasn't whitelisted and can't be converted to String
if ( ! method_exists($value, '__toString'))
{
throw new \RuntimeException('Object class "'.get_class($value).'" could not be converted to string or '.
'sanitized as ArrayAccess. Whitelist it in security.whitelisted_classes in app/config/config.php '.
'to allow it to be passed unchecked.');
}
$value = static::htmlentities((string) $value, $flags, $encoding, $double_encode);
config/config.phpを編集
config/config.phpに’Fuel\Core\Validation’,を追加します。
'whitelisted_classes' => array(
'Fuel\\Core\\Response',
'Fuel\\Core\\View',
'Fuel\\Core\\ViewModel',
'Fuel\\Core\\Validation',
'Closure',
),
これでエラーは出なくなります。