Changeset View
Changeset View
Standalone View
Standalone View
src/view/form/control/PHUIFormNumberControl.php
<?php | <?php | ||||
final class PHUIFormNumberControl extends AphrontFormControl { | final class PHUIFormNumberControl extends AphrontFormControl { | ||||
private $disableAutocomplete; | private $disableAutocomplete; | ||||
private $autofocus; | |||||
public function setDisableAutocomplete($disable_autocomplete) { | public function setDisableAutocomplete($disable_autocomplete) { | ||||
$this->disableAutocomplete = $disable_autocomplete; | $this->disableAutocomplete = $disable_autocomplete; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getDisableAutocomplete() { | public function getDisableAutocomplete() { | ||||
return $this->disableAutocomplete; | return $this->disableAutocomplete; | ||||
} | } | ||||
public function setAutofocus($autofocus) { | |||||
$this->autofocus = $autofocus; | |||||
return $this; | |||||
} | |||||
public function getAutofocus() { | |||||
return $this->autofocus; | |||||
} | |||||
protected function getCustomControlClass() { | protected function getCustomControlClass() { | ||||
return 'phui-form-number'; | return 'phui-form-number'; | ||||
} | } | ||||
protected function renderInput() { | protected function renderInput() { | ||||
if ($this->getDisableAutocomplete()) { | if ($this->getDisableAutocomplete()) { | ||||
$autocomplete = 'off'; | $autocomplete = 'off'; | ||||
} else { | } else { | ||||
$autocomplete = null; | $autocomplete = null; | ||||
} | } | ||||
return javelin_tag( | return javelin_tag( | ||||
'input', | 'input', | ||||
array( | array( | ||||
'type' => 'text', | 'type' => 'text', | ||||
'pattern' => '\d*', | 'pattern' => '\d*', | ||||
'name' => $this->getName(), | 'name' => $this->getName(), | ||||
'value' => $this->getValue(), | 'value' => $this->getValue(), | ||||
'disabled' => $this->getDisabled() ? 'disabled' : null, | 'disabled' => $this->getDisabled() ? 'disabled' : null, | ||||
'autocomplete' => $autocomplete, | 'autocomplete' => $autocomplete, | ||||
'id' => $this->getID(), | 'id' => $this->getID(), | ||||
'autofocus' => ($this->getAutofocus() ? 'autofocus' : null), | |||||
)); | )); | ||||
} | } | ||||
} | } |