21307 Posts in 5737 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1230 Views |
-
URL field

25 September 2010 at 6:42am
Hello everyone,
I'm currently working on a site that has a ComplexTableField with a field for adding links. What I would like is for people to put a url in here and for it to add in the http:// prefix if it hasn't already been entered.
Is there a specific field type for the back end that will do this for me?
Thanks
-
Re: URL field

25 September 2010 at 7:44pm
public function onBeforeWrite() {
parent::onBeforeWrite();
$url = $this->Website;
if($url) {
if(substr($url, 0, 8) != 'https://') {
if(substr($url, 0, 7) != 'http://') {
$url = $this->Website = 'http://' . $url;
}
}
}
$this->Website = strtolower($url);
} -
Re: URL field

25 September 2010 at 10:38pm
Thanks Martijn,
I thought there may have been a specific field type that would deal with it but your replacement is perfect!
Cheers
| 1230 Views | ||
|
Page:
1
|
Go to Top |


