This is how my yii2 model looks like:-
namespace app\models;
use Yii;
use yii\base\Model;
class UrlForm extends Model
{
public $url;
/**
* @return array the validation rules.
*/
public function rules()
{
return [
[['url'], 'required'],
['url', 'url'],
];
}
}
I want it to approve the url if use has not written 'http://' in the start.
Example:-
stackoverflow.com
should work fine.
http://stackoverflow.com
should work fine.
Current Status:-
stackoverflow.com
not accepted.
http://stackoverflow.com
is accepted..