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:
		| @@ -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); | ||||
|           } | ||||
|         } | ||||
|   | ||||
| @@ -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(); | ||||
|   } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 epriestley
					epriestley