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