Best way to validate custom attributes
Permalink
I've created some extra user attributes and want to validate them, what would be the best way to do it?
Currently I'm using this, but it seems bloated and maybe there is a simpler approach?
Currently I'm using this, but it seems bloated and maybe there is a simpler approach?
$ak = UserAttributeKey::getByHandle($akHandle); $postValue = $this->post('akID')[$ak->getAttributeKeyID()]['value']); if($postValue == 'blabla'){ // etc. }
Ok, yeah I was hoping for a more revolutionary solution ;)
For example, this code would probably give an error if the akHandle is not in de post request.
I guess a solution to this could be a helper like this:
$helper->post('ak_handle') and just returns the post value. The helper then needs to get the attribute key, check for an instance, check if the post parameters exist and return the value or null.
What do you think?
For example, this code would probably give an error if the akHandle is not in de post request.
I guess a solution to this could be a helper like this:
$helper->post('ak_handle') and just returns the post value. The helper then needs to get the attribute key, check for an instance, check if the post parameters exist and return the value or null.
What do you think?
It seems there is a validateAttributeForm function in /core/models/attribute/key.php. It checks and runs the function 'validateForm' in an attribute type model. For example /core/models/attribute/types/select.php.
I still haven't found nice way to validate individual attributes though.
I still haven't found nice way to validate individual attributes though.
A more out-of-the-box approach might be client-side validation is there a way to get jquery validation in there and use that?