An email input field with autocompletion and validation
The email field provides the most comfortable way to insert email addresses. It comes with autocompletion of addresses from all registered users and also has built-in validation for entered addresses.
Example
fields:
email:
label: Email
type: email
Example with switched off autocompletion
fields:
email:
label: Email
type: email
autocomplete: false
In your templates
You can simply echo the value of your email field in your templates like this:
<?= $page->email() ?>
However, if you want to make use of Kirby's built-in email obfuscation, you have several options:
Using html::email()
:
<?= html::email($page->email()) ?>
Using str::encode()
:
<a href="mailto:<?= str::encode($page->email()) ?>">
<?= str::encode($page->email()) ?>
</a>
Using the kirbytag()
helper:
<?= kirbytag([
'email' => $page->email(),
'text' => 'Contact us'
]);
?>