I'm using PHP to check for a very specific error condition and I've tried to return an updated value without success.
I'm assuming this module wasn't designed for this use case, but perhaps I'm overlooking something.
I'd like to check a URL for a 'http://' and if missing, add it, ala:
if ((strpos($this->value, "http://") == false) && (strpos($this->value, "https://") == false)) {
$this->value = 'http://' . $this->value;
return $this->value;
}
Comments
Comment #1
bisonbleu commentedI second this request and have changed the category to 'task'.
By default, the Link module will add the 'http://' if it is missing. This makes it more user friendly for average folks. I think 'Field validation', which does great things for admins, should build on this simple expectation and do the same.
The 'Link' module does it this way. Would this work for 'Field validation' ?
Comment #2
g089h515r806 commentedIt seems that we could not change field value in hook_field_attach_validate.
Maybe we could change it in other hooks.
Comment #3
g089h515r806 commented