silverstripe-userforms/code/model/editableformfields/EditableEmailField.php

40 lines
869 B
PHP
Raw Normal View History

<?php
/**
* EditableEmailField
*
* Allow users to define a validating editable email field for a UserDefinedForm
*
* @package userforms
*/
class EditableEmailField extends EditableFormField {
2015-09-11 00:20:06 +02:00
private static $singular_name = 'Email Field';
2015-09-11 00:20:06 +02:00
private static $plural_name = 'Email Fields';
2015-09-11 00:20:06 +02:00
public function getSetsOwnError() {
return true;
}
2015-09-11 00:20:06 +02:00
public function getFormField() {
$field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default)
->setFieldHolderTemplate('UserFormsField_holder')
->setTemplate('UserFormsField');
$this->doUpdateFormField($field);
return $field;
}
2015-09-11 00:20:06 +02:00
/**
2015-08-11 01:40:37 +02:00
* Updates a formfield with the additional metadata specified by this field
*
2015-08-11 01:40:37 +02:00
* @param FormField $field
*/
2015-08-11 01:40:37 +02:00
protected function updateFormField($field) {
parent::updateFormField($field);
$field->setAttribute('data-rule-email', true);
}
}