Differential D13200 Diff 31965 src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php
| Show All 31 Lines | public function renderEditControl(array $handles) { | ||||
| $all_levels = $this->getLevels(); | $all_levels = $this->getLevels(); | ||||
| $level = $this->getValue(); | $level = $this->getValue(); | ||||
| if (!$level) { | if (!$level) { | ||||
| $level = $this->getDefaultLevel(); | $level = $this->getDefaultLevel(); | ||||
| } | } | ||||
| $control = id(new AphrontFormRadioButtonControl()) | $control = id(new AphrontFormRadioButtonControl()) | ||||
| ->setLabel('Level') | ->setLabel(pht('Level')) | ||||
| ->setName($control_name) | ->setName($control_name) | ||||
| ->setValue($level); | ->setValue($level); | ||||
| if ($this->error) { | if ($this->error) { | ||||
| $control->setError($this->error); | $control->setError($this->error); | ||||
| } else if ($this->getDefaultLevel()) { | } else if ($this->getDefaultLevel()) { | ||||
| $control->setError(true); | $control->setError(true); | ||||
| } | } | ||||
| Show All 21 Lines | foreach ($levels as $level) { | ||||
| $text .= " {$default_marker} **{$name}**\n"; | $text .= " {$default_marker} **{$name}**\n"; | ||||
| $text .= phutil_console_wrap($description."\n", 8); | $text .= phutil_console_wrap($description."\n", 8); | ||||
| } | } | ||||
| return $text; | return $text; | ||||
| } | } | ||||
| public function validate($value) { | public function validate($value) { | ||||
| if ($value === null) { | if ($value === null) { | ||||
| $this->error = 'Required'; | $this->error = pht('Required'); | ||||
| $label = $this->getName(); | $label = $this->getName(); | ||||
| throw new ReleephFieldParseException( | throw new ReleephFieldParseException( | ||||
| $this, | $this, | ||||
| pht('You must provide a %s level.', $label)); | pht('You must provide a %s level.', $label)); | ||||
| } | } | ||||
| $levels = $this->getLevels(); | $levels = $this->getLevels(); | ||||
| if (!in_array($value, $levels)) { | if (!in_array($value, $levels)) { | ||||
| ▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines | |||||