I am developing an application in
By using alpha
as the first rule, you are limiting the entry to only letters. With this rule you are forbidding spaces, commas or points to enter. You have to eliminate that rule:
$crud->set_rules( 'marca', 'Marca', 'callback_solo_letras' );
On the other hand, the regular expression should
^
. \s
allows any blank space or [ \t\r\n\f]
) /^[a-z ,.]*$/i
And the function would be:
public function solo_letras($cadena)
{
return preg_match( '/^[a-z ,.]*$/i', $cadena );
}
However, it is much easier to use the rule regex_match[/regex/]
$crud->set_rules( 'marca', 'Marca', 'regex_match[/^[a-z ,.]*$/i]' );
Or if you want to allow ñ
and other letters of Spanish:
$crud->set_rules( 'marca', 'Marca', 'regex_match[/^[a-zñáéíóúüA-ZÑÁÉÍÓÚÜ ,.]*$/u]' );
Or any letter of any alphabet (general category Letter from Unicode).
$crud->set_rules( 'marca', 'Marca', 'regex_match[/^[\p{L} ,.]*$/u]' );