1
0
Fork 0
feedizer-php/htdocs/libraries/Nibble-Forms/Nibble/NibbleForms/Field/Url.php

34 lines
707 B
PHP
Raw Permalink Normal View History

2015-11-13 23:51:46 +01:00
<?php
namespace Nibble\NibbleForms\Field;
use Nibble\NibbleForms\Useful;
class Url extends Text
{
public function validate($val)
{
if (!empty($this->error)) {
return false;
}
if (parent::validate($val)) {
if (Useful::stripper($val) !== false) {
if (!filter_var($val, FILTER_VALIDATE_URL)) {
$this->error[] = 'must be a valid URL';
}
}
}
return !empty($this->error) ? false : true;
}
public function returnField($form_name, $name, $value = '')
{
$this->field_type = 'url';
return parent::returnField($form_name, $name, $value);
}
}