Page MenuHomePhabricator

D16195.id.diff
No OneTemporary

D16195.id.diff

diff --git a/src/view/form/control/AphrontFormControl.php b/src/view/form/control/AphrontFormControl.php
--- a/src/view/form/control/AphrontFormControl.php
+++ b/src/view/form/control/AphrontFormControl.php
@@ -67,6 +67,10 @@
}
public function setError($error) {
+ if ($error === true) {
+ return $this->setRequired(true);
+ }
+
$this->error = $error;
return $this;
}
@@ -109,6 +113,11 @@
return $this->required;
}
+ public function setRequired($required) {
+ $this->required = $required;
+ return $this;
+ }
+
public function isEmpty() {
return !strlen($this->getValue());
}
@@ -190,17 +199,15 @@
$error = null;
if (strlen($this->getError())) {
$error = $this->getError();
- if ($error === true) {
- $error = phutil_tag(
- 'span',
- array('class' => 'aphront-form-error aphront-form-required'),
- pht('Required'));
- } else {
- $error = phutil_tag(
- 'span',
- array('class' => 'aphront-form-error'),
- $error);
- }
+ $error = phutil_tag(
+ 'span',
+ array('class' => 'aphront-form-error'),
+ $error);
+ } else if ($this->isRequired()) {
+ $error = phutil_tag(
+ 'span',
+ array('class' => 'aphront-form-error aphront-form-required'),
+ pht('Required'));
}
if (strlen($this->getLabel())) {

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 15, 7:25 PM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7702296
Default Alt Text
D16195.id.diff (1 KB)

Event Timeline