mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Add placeholder to Numeric and Email fields
This commit is contained in:
parent
da2aba8229
commit
c3b3e1cc7a
@ -13,6 +13,24 @@ class EditableEmailField extends EditableFormField {
|
||||
|
||||
private static $plural_name = 'Email Fields';
|
||||
|
||||
private static $db = array(
|
||||
'Placeholder' => 'Varchar(255)'
|
||||
);
|
||||
|
||||
public function getCMSFields() {
|
||||
$this->beforeUpdateCMSFields(function($fields) {
|
||||
$fields->addFieldToTab(
|
||||
'Root.Main',
|
||||
TextField::create(
|
||||
'Placeholder',
|
||||
_t('EditableTextField.PLACEHOLDER', 'Placeholder')
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
return parent::getCMSFields();
|
||||
}
|
||||
|
||||
public function getSetsOwnError() {
|
||||
return true;
|
||||
}
|
||||
@ -36,5 +54,9 @@ class EditableEmailField extends EditableFormField {
|
||||
parent::updateFormField($field);
|
||||
|
||||
$field->setAttribute('data-rule-email', true);
|
||||
|
||||
if($this->Placeholder) {
|
||||
$field->setAttribute('placeholder', $this->Placeholder);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,13 +15,28 @@ class EditableNumericField extends EditableFormField {
|
||||
|
||||
private static $db = array(
|
||||
'MinValue' => 'Int',
|
||||
'MaxValue' => 'Int'
|
||||
'MaxValue' => 'Int',
|
||||
'Placeholder' => 'Varchar(255)'
|
||||
);
|
||||
|
||||
public function getSetsOwnError() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCMSFields() {
|
||||
$this->beforeUpdateCMSFields(function($fields) {
|
||||
$fields->addFieldToTab(
|
||||
'Root.Main',
|
||||
TextField::create(
|
||||
'Placeholder',
|
||||
_t('EditableTextField.PLACEHOLDER', 'Placeholder')
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
return parent::getCMSFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NumericField
|
||||
*/
|
||||
@ -64,5 +79,9 @@ class EditableNumericField extends EditableFormField {
|
||||
if($this->MaxValue) {
|
||||
$field->setAttribute('data-rule-max', $this->MaxValue);
|
||||
}
|
||||
|
||||
if($this->Placeholder) {
|
||||
$field->setAttribute('placeholder', $this->Placeholder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user