[eluser]davste[/eluser]
Hi,
I've gotten to discover an "error" or bug, if you don't include "require" in the set_rules() function.
Example shown below:
Code:
$this->form_validation->set_rules ('new_folder', 'Folder name', 'callback__convert_whitespace|alpha_dash');
_convert_whitespace () is a function that replaces whitespaces with -A1234A- (because alpha_dash does not support whitespace). If I remove the callback, everything works.
If I use "require" also, the form wont be submitted if the input value is something like "< script >".
If I use the code above, _everything_ passes although I have "alpha_dash". What to do?
Code:
function _convert_whitespace ($str) {
return str_replace (' ', '-123ABA-', $str);
}
It just does not make any sense.
What I want to do:
* Field is optional
* If data, check for a valid name (alpha_dash). Also accept whitespace