2008-09-29 03:18:23 +00:00
|
|
|
<?php
|
2017-08-09 11:55:09 +12:00
|
|
|
|
|
|
|
namespace SilverStripe\UserForms\Model\EditableFormField;
|
|
|
|
|
|
|
|
use SilverStripe\Forms\EmailField;
|
2017-08-11 11:33:06 +12:00
|
|
|
use SilverStripe\UserForms\Model\EditableFormField;
|
2017-08-09 11:55:09 +12:00
|
|
|
|
2008-09-29 03:18:23 +00:00
|
|
|
/**
|
|
|
|
* EditableEmailField
|
2009-04-17 02:26:40 +00:00
|
|
|
*
|
2008-09-29 03:18:23 +00:00
|
|
|
* Allow users to define a validating editable email field for a UserDefinedForm
|
2009-04-17 02:26:40 +00:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 03:18:23 +00:00
|
|
|
*/
|
2009-12-07 02:04:20 +00:00
|
|
|
|
2016-07-21 17:53:59 +12:00
|
|
|
class EditableEmailField extends EditableFormField
|
|
|
|
{
|
|
|
|
private static $singular_name = 'Email Field';
|
|
|
|
|
|
|
|
private static $plural_name = 'Email Fields';
|
|
|
|
|
2017-04-28 18:01:51 +09:30
|
|
|
private static $has_placeholder = true;
|
2016-07-21 17:53:59 +12:00
|
|
|
|
2017-08-11 11:33:06 +12:00
|
|
|
private static $table_name = 'EditableEmailField';
|
|
|
|
|
2016-07-21 17:53:59 +12:00
|
|
|
public function getSetsOwnError()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFormField()
|
|
|
|
{
|
|
|
|
$field = EmailField::create($this->Name, $this->EscapedTitle, $this->Default)
|
|
|
|
->setFieldHolderTemplate('UserFormsField_holder')
|
2017-08-14 12:29:57 +12:00
|
|
|
->setTemplate(EditableFormField::class);
|
2016-07-21 17:53:59 +12:00
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|