Skip to content

Commit

Permalink
empty text for base urls
Browse files Browse the repository at this point in the history
  • Loading branch information
nateiler committed Apr 9, 2019
1 parent 11bd39e commit 4cdc0fc
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/types/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Url extends AbstractType
*/
const INPUT_TEMPLATE_PATH = self::BASE_TEMPLATE_PATH . '/input';

/**
* @var bool
*/
public $allowEmptyText = true;

/**
* @var
*/
Expand All @@ -47,6 +52,18 @@ public static function displayName(): string
return \flipbox\craft\link\Link::t('Url');
}

/**
* @inheritdoc
*/
public function getText()
{
if ($this->allowText && $this->overrideText !== null) {
return $this->overrideText;
}

return $this->allowEmptyText ? null : $this->getUrl();
}

/**
* @return string
*/
Expand All @@ -63,7 +80,8 @@ public function settings(): array
return array_merge(
parent::settings(),
[
'placeholder'
'placeholder',
'allowEmptyText'
]
);
}
Expand Down Expand Up @@ -110,7 +128,7 @@ public function rules()
],
[
[
'url'
'url',
],
'safe',
'on' => [
Expand Down

0 comments on commit 4cdc0fc

Please sign in to comment.