Changeset View
Changeset View
Standalone View
Standalone View
src/view/form/control/AphrontFormSubmitControl.php
| <?php | <?php | ||||
| final class AphrontFormSubmitControl extends AphrontFormControl { | final class AphrontFormSubmitControl extends AphrontFormControl { | ||||
| private $buttons = array(); | private $buttons = array(); | ||||
| private $sigils = array(); | |||||
| public function addCancelButton($href, $label = null) { | public function addCancelButton($href, $label = null) { | ||||
| if (!$label) { | if (!$label) { | ||||
| $label = pht('Cancel'); | $label = pht('Cancel'); | ||||
| } | } | ||||
| $button = id(new PHUIButtonView()) | $button = id(new PHUIButtonView()) | ||||
| ->setTag('a') | ->setTag('a') | ||||
| ->setHref($href) | ->setHref($href) | ||||
| ->setText($label) | ->setText($label) | ||||
| ->setColor(PHUIButtonView::GREY); | ->setColor(PHUIButtonView::GREY); | ||||
| $this->addButton($button); | $this->addButton($button); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function addButton(PHUIButtonView $button) { | public function addButton(PHUIButtonView $button) { | ||||
| $this->buttons[] = $button; | $this->buttons[] = $button; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function addSigil($sigil) { | |||||
| $this->sigils[] = $sigil; | |||||
| return $this; | |||||
| } | |||||
| protected function getCustomControlClass() { | protected function getCustomControlClass() { | ||||
| return 'aphront-form-control-submit'; | return 'aphront-form-control-submit'; | ||||
| } | } | ||||
| protected function renderInput() { | protected function renderInput() { | ||||
| $submit_button = null; | $submit_button = null; | ||||
| if ($this->getValue()) { | if ($this->getValue()) { | ||||
| $submit_button = phutil_tag( | |||||
| if ($this->sigils) { | |||||
| $sigils = $this->sigils; | |||||
| } else { | |||||
| $sigils = null; | |||||
| } | |||||
| $submit_button = javelin_tag( | |||||
| 'button', | 'button', | ||||
| array( | array( | ||||
| 'type' => 'submit', | 'type' => 'submit', | ||||
| 'name' => '__submit__', | 'name' => '__submit__', | ||||
| 'sigil' => $sigils, | |||||
| 'disabled' => $this->getDisabled() ? 'disabled' : null, | 'disabled' => $this->getDisabled() ? 'disabled' : null, | ||||
| ), | ), | ||||
| $this->getValue()); | $this->getValue()); | ||||
| } | } | ||||
| return array( | return array( | ||||
| $submit_button, | $submit_button, | ||||
| $this->buttons, | $this->buttons, | ||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||