mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\UserForms\Model\EditableFormField;
|
|
|
|
|
|
use SilverStripe\Forms\EmailField;
|
|
|
|
|
|
/**
|
|
* EditableEmailField
|
|
*
|
|
* Allow users to define a validating editable email field for a UserDefinedForm
|
|
*
|
|
* @package userforms
|
|
*/
|
|
|
|
class EditableEmailField extends EditableFormField
|
|
{
|
|
|
|
private static $singular_name = 'Email Field';
|
|
|
|
private static $plural_name = 'Email Fields';
|
|
|
|
private static $has_placeholder = true;
|
|
|
|
public function getSetsOwnError()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function getFormField()
|
|
{
|
|
$field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default)
|
|
->setFieldHolderTemplate('UserFormsField_holder')
|
|
->setTemplate('UserFormsField');
|
|
|
|
$this->doUpdateFormField($field);
|
|
|
|
return $field;
|
|
}
|
|
|
|
/**
|
|
* Updates a formfield with the additional metadata specified by this field
|
|
*
|
|
* @param FormField $field
|
|
*/
|
|
protected function updateFormField($field)
|
|
{
|
|
parent::updateFormField($field);
|
|
|
|
$field->setAttribute('data-rule-email', true);
|
|
}
|
|
}
|