You are using preg_grep
which uses an array as input, but you are giving at a string by your foreach.
I think the easiest would be using something like the following code:
$options = array('#fffAA9', '#a65c23');
foreach ($options as $value)
{
preg_match('/(#[a-f0-9]{3}([a-f0-9]{3})?)/i', $value, $matches);
if (isset($matches[1]))
{
// validated ok
var_dump($matches[1]);
}
else
{
// no match
}
}
edit: Alternativly you can do it with preg_grep even simpler:
public function actionValidate($options)
{
// $options = array('#fffAA9', '#a65c23');
return preg_grep('/^(#[a-f0-9]{3}([a-f0-9]{3})?)$/i', $options);
}