Pergunta

It appears I can use PHP's strip_tags function within Codeigniter's form validation like this:

$this->form_validation->set_rules('description', 'Description', 
                              'trim|xss_clean|strip_tags');

Strip_tags supports an allowable_tags parameter to list tags to exclude from the filtering e.g. keep <h1>, <strong> etc.

How can I use this within the form validation syntax?

Foi útil?

Solução

$this->form_validation->set_rules('description', 'Description', 'callback_description_check');

public function direction_check($str)
{
    return strip_tags($text, '<p><a>'); 
}

Best way would be to create your own callback function, which you can modify according to your needs.

Outras dicas

you could make a callback

function callback_strip_tags_custom($text)
{
 return strip_tags($text, '<p><a>');

}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top