Presenter Output
This section will show you how to use the decorated value provided by the \Anomaly\TextFieldType\TextFieldTypePresenter class.
TextFieldTypePresenter::preg()
The preg method performs a preg_replace on the value.
Returns: string
Arguments
| Key | Required | Type | Default | Description |
|---|---|---|---|---|
|
$pattern |
'/[^+\d]/' |
string |
None |
The pre_replace pattern. Note that Twig requires backslashes to be escaped. |
|
$replace |
'#' |
string |
"" |
The replacement text for the preg_replace. |
Example
$decorated->example->preg('/[^\+\d]/');
Twig
{{ decorated.example.preg('/[^\\+\\d]/') }}
Note you have to escape backslashes in Twig usage.
TextFieldTypePresenter::tel()
The tel method returns an HTML tel link.
Returns: string
Arguments
| Key | Required | Type | Default | Description |
|---|---|---|---|---|
|
$text |
false |
string |
The phone number as entered. |
The text of the link. |
|
$attributes |
false |
array |
null |
The HTML attributes of the link. |
Example
$decorated->example->tel('Call me!', ['class'
=> 'btn btn-success']);
Twig
{{ decorated.example.tel('Call me!'<
span class="token punctuation">, {'class': 'btn btn-success'})|raw }}
TextFieldTypePresenter::sms()
The sms method returns an HTML sms link.
Returns: string
Arguments
| Key | Required | Type | Default | Description |
|---|---|---|---|---|
|
$text |
false |
string |
The phone number as entered. |
The text of the link. |
|
$attributes |
false |
array |
null |
The HTML attributes of the link. |
Example
$decorated->example->sms('Text me!', ['class'
=> 'btn btn-success']);
Twig
{{ decorated.example.sms('Text me!'<
span class="token punctuation">, {'class': 'btn btn-success'})|raw }}