mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Added placeholder support to custom text fields
Summary: placeholder text is pretty useful. Test Plan: placeholder text is pretty useful. also fully supports not breaking everything. Reviewers: chad, #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9223
This commit is contained in:
parent
3c8d88deb4
commit
2133e61048
4 changed files with 35 additions and 1 deletions
|
@ -103,6 +103,8 @@ When defining custom fields using a configuration option like
|
|||
type. See below.
|
||||
- **instructions**: Optional block of remarkup text which will appear
|
||||
above the control when rendered on the edit view.
|
||||
- **placeholder**: A placeholder text that appears on text boxes. Only
|
||||
supported in text, int and remarkup fields (optional).
|
||||
|
||||
The `strings` value supports different strings per control type. They are:
|
||||
|
||||
|
|
|
@ -215,13 +215,18 @@ abstract class PhabricatorStandardCustomField
|
|||
return $this->getFieldConfigValue('instructions');
|
||||
}
|
||||
|
||||
public function getPlaceholder() {
|
||||
return $this->getFieldConfigValue('placeholder', null);
|
||||
}
|
||||
|
||||
public function renderEditControl(array $handles) {
|
||||
return id(new AphrontFormTextControl())
|
||||
->setName($this->getFieldKey())
|
||||
->setCaption($this->getCaption())
|
||||
->setValue($this->getFieldValue())
|
||||
->setError($this->getFieldError())
|
||||
->setLabel($this->getFieldName());
|
||||
->setLabel($this->getFieldName())
|
||||
->setPlaceholder($this->getPlaceholder());
|
||||
}
|
||||
|
||||
public function newStorageObject() {
|
||||
|
|
|
@ -4,18 +4,30 @@ final class AphrontFormTextControl extends AphrontFormControl {
|
|||
|
||||
private $disableAutocomplete;
|
||||
private $sigil;
|
||||
private $placeholder;
|
||||
|
||||
public function setDisableAutocomplete($disable) {
|
||||
$this->disableAutocomplete = $disable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getDisableAutocomplete() {
|
||||
return $this->disableAutocomplete;
|
||||
}
|
||||
|
||||
public function getPlaceholder() {
|
||||
return $this->placeholder;
|
||||
}
|
||||
|
||||
public function setPlaceholder($placeholder) {
|
||||
$this->placeholder = $placeholder;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSigil() {
|
||||
return $this->sigil;
|
||||
}
|
||||
|
||||
public function setSigil($sigil) {
|
||||
$this->sigil = $sigil;
|
||||
return $this;
|
||||
|
@ -36,6 +48,7 @@ final class AphrontFormTextControl extends AphrontFormControl {
|
|||
'autocomplete' => $this->getDisableAutocomplete() ? 'off' : null,
|
||||
'id' => $this->getID(),
|
||||
'sigil' => $this->getSigil(),
|
||||
'placeholder' => $this->getPlaceholder()
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,20 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.aphront-form-input *::-webkit-input-placeholder {
|
||||
color:{$greytext} !important;
|
||||
}
|
||||
|
||||
.aphront-form-input *::-moz-placeholder {
|
||||
color:{$greytext} !important;
|
||||
opacity: 1; /* Firefox nudges the opacity to 0.4 */
|
||||
}
|
||||
|
||||
.aphront-form-input *:-ms-input-placeholder {
|
||||
color:{$greytext} !important;
|
||||
}
|
||||
|
||||
|
||||
.aphront-form-error {
|
||||
width: 18%;
|
||||
float: right;
|
||||
|
|
Loading…
Reference in a new issue