SneakyDave
Well-known member
A couple of questions regarding assigning validation callbacks to option fields to validate or render them.
It appears that if a callback is assigned to an option, to validate the value, that callback is also executed when the addon is installed.
So, for instance, let's say I have an string option that requires a value to be entered. So I create a validation callback that throws a DataWriter error and returns false if the option is empty. In this case, the addon can't be installed, because the installation routine exist with that error.
I could create the option with a default value, mabe "This field is required..." but that's just a little sloppy.
I was wondering if 1) There's a way to tell if the callback is being called from the install routine or from saving the options and 2) If that's really the best way to handle this type of event.
The other question I have is regarding sanitizing/cleaning the admin options. If I have a text box as an admin option, is there a filter method I can apply similar to $this->_input->filterSingle() that I can use in a validation callback?
It appears that if a callback is assigned to an option, to validate the value, that callback is also executed when the addon is installed.
So, for instance, let's say I have an string option that requires a value to be entered. So I create a validation callback that throws a DataWriter error and returns false if the option is empty. In this case, the addon can't be installed, because the installation routine exist with that error.
I could create the option with a default value, mabe "This field is required..." but that's just a little sloppy.
I was wondering if 1) There's a way to tell if the callback is being called from the install routine or from saving the options and 2) If that's really the best way to handle this type of event.
The other question I have is regarding sanitizing/cleaning the admin options. If I have a text box as an admin option, is there a filter method I can apply similar to $this->_input->filterSingle() that I can use in a validation callback?