Add an "instructions" key to custom fields

Summary: Ref T1049. I'm planning to use this in Harbormaster custom fields shortly.

Test Plan: {F133843}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1049

Differential Revision: https://secure.phabricator.com/D8606
This commit is contained in:
epriestley
2014-03-25 16:12:49 -07:00
parent 6e3c17e6f9
commit acfc3c3e5d
4 changed files with 23 additions and 0 deletions

View File

@@ -101,6 +101,8 @@ When defining custom fields using a configuration option like
- **default**: Default field value. - **default**: Default field value.
- **strings**: Allows you to override specific strings based on the field - **strings**: Allows you to override specific strings based on the field
type. See below. type. See below.
- **instructions**: Optional block of remarkup text which will appear
above the control when rendered on the edit view.
The `strings` value supports different strings per control type. They are: The `strings` value supports different strings per control type. They are:

View File

@@ -1060,6 +1060,17 @@ abstract class PhabricatorCustomField {
} }
/**
* @task edit
*/
public function getInstructionsForEdit() {
if ($this->proxy) {
return $this->proxy->getInstructionsForEdit();
}
return null;
}
/** /**
* @task edit * @task edit
*/ */

View File

@@ -108,6 +108,12 @@ final class PhabricatorCustomFieldList extends Phobject {
foreach ($enabled as $field_key => $field) { foreach ($enabled as $field_key => $field) {
$field_handles = array_select_keys($handles, $phids[$field_key]); $field_handles = array_select_keys($handles, $phids[$field_key]);
$instructions = $field->getInstructionsForEdit();
if (strlen($instructions)) {
$form->appendRemarkupInstructions($instructions);
}
$form->appendChild($field->renderEditControl($field_handles)); $form->appendChild($field->renderEditControl($field_handles));
} }
} }

View File

@@ -211,6 +211,10 @@ abstract class PhabricatorStandardCustomField
$this->setFieldValue($value); $this->setFieldValue($value);
} }
public function getInstructionsForEdit() {
return $this->getFieldConfigValue('instructions');
}
public function renderEditControl(array $handles) { public function renderEditControl(array $handles) {
return id(new AphrontFormTextControl()) return id(new AphrontFormTextControl())
->setName($this->getFieldKey()) ->setName($this->getFieldKey())