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:
@@ -101,6 +101,8 @@ When defining custom fields using a configuration option like
|
||||
- **default**: Default field value.
|
||||
- **strings**: Allows you to override specific strings based on the field
|
||||
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:
|
||||
|
||||
|
||||
@@ -1060,6 +1060,17 @@ abstract class PhabricatorCustomField {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @task edit
|
||||
*/
|
||||
public function getInstructionsForEdit() {
|
||||
if ($this->proxy) {
|
||||
return $this->proxy->getInstructionsForEdit();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @task edit
|
||||
*/
|
||||
|
||||
@@ -108,6 +108,12 @@ final class PhabricatorCustomFieldList extends Phobject {
|
||||
|
||||
foreach ($enabled as $field_key => $field) {
|
||||
$field_handles = array_select_keys($handles, $phids[$field_key]);
|
||||
|
||||
$instructions = $field->getInstructionsForEdit();
|
||||
if (strlen($instructions)) {
|
||||
$form->appendRemarkupInstructions($instructions);
|
||||
}
|
||||
|
||||
$form->appendChild($field->renderEditControl($field_handles));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +211,10 @@ abstract class PhabricatorStandardCustomField
|
||||
$this->setFieldValue($value);
|
||||
}
|
||||
|
||||
public function getInstructionsForEdit() {
|
||||
return $this->getFieldConfigValue('instructions');
|
||||
}
|
||||
|
||||
public function renderEditControl(array $handles) {
|
||||
return id(new AphrontFormTextControl())
|
||||
->setName($this->getFieldKey())
|
||||
|
||||
Reference in New Issue
Block a user