Filter options (advanced)

You can pass in options to filters to change the way they operate. You can pass in options using the addFilter() method on an element. Pass in an array as the second argument containing the array keys that are options of the filter. See the documentation below on each filter or the code for the filters in the quform/lib/Quform/Filter/ folder to see the options you can use.

1
$element->addFilter('stripTags', array('allowableTags' => array('<br>', '<p>')));
$element->addFilter('stripTags', array('allowableTags' => array('<br>', '<p>')));

You can also pass in options at instantiation and then add the filter object to your element.

1
2
$stripTagsFilter = new Quform_Filter_StripTags(array('allowableTags' => array('<br>')));
$element->addFilter($stripTagsFilter);
$stripTagsFilter = new Quform_Filter_StripTags(array('allowableTags' => array('<br>')));
$element->addFilter($stripTagsFilter);

Alpha filter

Options

  • allowWhiteSpace – boolean true or false, if true white space is not filtered, default false
1
$element->addFilter('alpha', array('allowWhiteSpace' => true));
$element->addFilter('alpha', array('allowWhiteSpace' => true));

Alphanumeric filter

Options

  • allowWhiteSpace – boolean true or false, if true white space is not filtered, default false
1
$element->addFilter('alphaNumeric', array('allowWhiteSpace' => true));
$element->addFilter('alphaNumeric', array('allowWhiteSpace' => true));

Digits filter

Options

  • allowWhiteSpace – boolean true or false, if true white space is not filtered, default false
1
$element->addFilter('digits', array('allowWhiteSpace' => true));
$element->addFilter('digits', array('allowWhiteSpace' => true));

Filename filter

No options.

1
$element->addFilter('filename');
$element->addFilter('filename');

Regex filter

Options

  • pattern – string regex pattern passed as-is to preg_replace
1
$element->addFilter('regex', array('pattern' => '/\d+/'));
$element->addFilter('regex', array('pattern' => '/\d+/'));

StripTags filter

Options

  • allowableTags – an array of strings of the tags you do not want to be stripped
1
$element->addFilter('stripTags', array('allowableTags' => array('<br>', '<p>')));
$element->addFilter('stripTags', array('allowableTags' => array('<br>', '<p>')));

Trim filter

No options.

1
$element->addFilter('trim');
$element->addFilter('trim');
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy