1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 08:20:57 +01:00

Prevent "Spaces" field from being set to inconsistent values

Summary:
At least for now, the "Space" field is just a subfield of the "Visible To" field, so:

  - it doesn't get any separate settings; and
  - it always uses the "Visible To" settings.

Test Plan:
  - Created a form with a hidden view policy field.
  - Created stuff with no "you must pick a space" errors.
  - Created stuff with a normal form.
  - Prefilled "Space" on a noraml form.
  - Verified that trying to prefill "Space" on a form with "Visible To" hidden does nothing.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D14812
This commit is contained in:
epriestley 2015-12-17 11:00:47 -08:00
parent bd7981c750
commit ed43b31cb1
2 changed files with 22 additions and 0 deletions

View file

@ -101,6 +101,7 @@ final class PhabricatorPolicyEditEngineExtension
->setLabel(pht('Space'))
->setEditTypeKey('space')
->setIsCopyable(true)
->setIsLockable(false)
->setIsReorderable(false)
->setAliases(array('space', 'policy.space'))
->setTransactionType($type_space)
@ -111,6 +112,7 @@ final class PhabricatorPolicyEditEngineExtension
->setValue($object->getSpacePHID());
$fields[] = $space_field;
$space_field->setPolicyField($policy_field);
$policy_field->setSpaceField($space_field);
}
}

View file

@ -3,6 +3,17 @@
final class PhabricatorSpaceEditField
extends PhabricatorEditField {
private $policyField;
public function setPolicyField(PhabricatorPolicyEditField $policy_field) {
$this->policyField = $policy_field;
return $this;
}
public function getPolicyField() {
return $this->policyField;
}
protected function newControl() {
// NOTE: This field doesn't do anything on its own, it just serves as a
// companion to the associated View Policy field.
@ -17,4 +28,13 @@ final class PhabricatorSpaceEditField
return new ConduitPHIDParameterType();
}
public function shouldReadValueFromRequest() {
return $this->getPolicyField()->shouldReadValueFromRequest();
}
public function shouldReadValueFromSubmit() {
return $this->getPolicyField()->shouldReadValueFromSubmit();
}
}