1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +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:
Tal Shiri 2014-05-22 09:12:54 -07:00 committed by epriestley
parent 3c8d88deb4
commit 2133e61048
4 changed files with 35 additions and 1 deletions

View file

@ -103,6 +103,8 @@ When defining custom fields using a configuration option like
type. See below. type. See below.
- **instructions**: Optional block of remarkup text which will appear - **instructions**: Optional block of remarkup text which will appear
above the control when rendered on the edit view. 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: The `strings` value supports different strings per control type. They are:

View file

@ -215,13 +215,18 @@ abstract class PhabricatorStandardCustomField
return $this->getFieldConfigValue('instructions'); return $this->getFieldConfigValue('instructions');
} }
public function getPlaceholder() {
return $this->getFieldConfigValue('placeholder', null);
}
public function renderEditControl(array $handles) { public function renderEditControl(array $handles) {
return id(new AphrontFormTextControl()) return id(new AphrontFormTextControl())
->setName($this->getFieldKey()) ->setName($this->getFieldKey())
->setCaption($this->getCaption()) ->setCaption($this->getCaption())
->setValue($this->getFieldValue()) ->setValue($this->getFieldValue())
->setError($this->getFieldError()) ->setError($this->getFieldError())
->setLabel($this->getFieldName()); ->setLabel($this->getFieldName())
->setPlaceholder($this->getPlaceholder());
} }
public function newStorageObject() { public function newStorageObject() {

View file

@ -4,18 +4,30 @@ final class AphrontFormTextControl extends AphrontFormControl {
private $disableAutocomplete; private $disableAutocomplete;
private $sigil; private $sigil;
private $placeholder;
public function setDisableAutocomplete($disable) { public function setDisableAutocomplete($disable) {
$this->disableAutocomplete = $disable; $this->disableAutocomplete = $disable;
return $this; return $this;
} }
private function getDisableAutocomplete() { private function getDisableAutocomplete() {
return $this->disableAutocomplete; return $this->disableAutocomplete;
} }
public function getPlaceholder() {
return $this->placeholder;
}
public function setPlaceholder($placeholder) {
$this->placeholder = $placeholder;
return $this;
}
public function getSigil() { public function getSigil() {
return $this->sigil; return $this->sigil;
} }
public function setSigil($sigil) { public function setSigil($sigil) {
$this->sigil = $sigil; $this->sigil = $sigil;
return $this; return $this;
@ -36,6 +48,7 @@ final class AphrontFormTextControl extends AphrontFormControl {
'autocomplete' => $this->getDisableAutocomplete() ? 'off' : null, 'autocomplete' => $this->getDisableAutocomplete() ? 'off' : null,
'id' => $this->getID(), 'id' => $this->getID(),
'sigil' => $this->getSigil(), 'sigil' => $this->getSigil(),
'placeholder' => $this->getPlaceholder()
)); ));
} }

View file

@ -49,6 +49,20 @@
width: 100%; 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 { .aphront-form-error {
width: 18%; width: 18%;
float: right; float: right;