Page MenuHomePhabricator

D17593.diff
No OneTemporary

D17593.diff

diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php
--- a/src/applications/maniphest/editor/ManiphestEditEngine.php
+++ b/src/applications/maniphest/editor/ManiphestEditEngine.php
@@ -465,5 +465,20 @@
return $map;
}
+ protected function willConfigureFields($object, array $fields) {
+ $subtype = $this->getEditEngineConfiguration()->getSubType();
+ if ($subtype) {
+ foreach ($fields as $key => $field) {
+ if ($field instanceof PhabricatorCustomFieldEditField) {
+ $subtypes = $field->getCustomField()->getFieldConfigValue('subtypes');
+ if ($subtypes && !in_array($subtype, $subtypes)) {
+ unset($fields[$key]);
+ }
+ }
+ }
+ }
+
+ return $fields;
+ }
}
diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
--- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -2120,6 +2120,18 @@
$object,
$xactions,
$type);
+
+ /* XXX: This is nasty. We can't otherwise validate that a given field
+ * is appropriate for the subtype, because we don't have access
+ * to the EditEngine's configuration, if it even has one.
+ * Ideally we should do this in two passes, where we sweep all
+ * the transactions looking for a subtype, set it on the
+ * TransactionEditor, and can then access that from validation. */
+ if ($this->getIsNewObject() && !empty($xactions)) {
+ foreach ($xactions as $xaction) {
+ $object->setEditEngineSubtype($xaction->getNewValue());
+ }
+ }
break;
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
$groups = array();
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
@@ -345,6 +345,17 @@
$type,
$xactions);
+ $object = $this->getObject();
+ if ($object instanceof PhabricatorEditEngineSubtypeInterface) {
+ $subtype = $object->getEditEngineSubtype();
+ if ($subtype) {
+ $subtypes = $this->getFieldConfigValue('subtypes');
+ if ($subtypes && !in_array($subtype, $subtypes)) {
+ return $errors;
+ }
+ }
+ }
+
if ($this->getRequired()) {
$value = $this->getOldValueForApplicationTransactions();

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 10:23 AM (11 h, 36 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6782245
Default Alt Text
D17593.diff (2 KB)

Event Timeline