Reputation: 7294
I have a field in yii which needs url input only. I use url validation of yii.
array('source_link','url')
but this is validating both http and https. I want to use only https.I used defaultScheme.
array('source_link','url', 'defaultScheme'=>'https')
but it is still same.
Upvotes: 0
Views: 1115
Reputation: 1981
defaultScheme
param is for prepending prefix to url, for example http
, if there is no prefix like that. From documentation:
public string $defaultScheme;
the default URI scheme. If the input doesn't contain the scheme part, the default scheme will be prepended to it (thus changing the input). Defaults to null, meaning a URL must contain the scheme part.
You should use validSchemes
:
public array $validSchemes;
list of URI schemes which should be considered valid. By default, http and https are considered to be valid schemes.
So you rule should looks like this:
array('source_link','url', 'validSchemes'=>array('https'))
Upvotes: 1