Changeset View
Changeset View
Standalone View
Standalone View
src/view/form/control/AphrontFormTokenizerControl.php
Show All 26 Lines | final class AphrontFormTokenizerControl extends AphrontFormControl { | ||||
} | } | ||||
public function setPlaceholder($placeholder) { | public function setPlaceholder($placeholder) { | ||||
$this->placeholder = $placeholder; | $this->placeholder = $placeholder; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function renderInput() { | protected function renderInput() { | ||||
if (!$this->getUser()) { | |||||
throw new Exception( | |||||
pht( | |||||
'Call setUser() before rendering an AphrontFormTokenizerControl.')); | |||||
} | |||||
$name = $this->getName(); | $name = $this->getName(); | ||||
$values = nonempty($this->getValue(), array()); | $values = nonempty($this->getValue(), array()); | ||||
assert_instances_of($values, 'PhabricatorObjectHandle'); | assert_instances_of($values, 'PhabricatorObjectHandle'); | ||||
if ($this->getID()) { | if ($this->getID()) { | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
} else { | } else { | ||||
$id = celerity_generate_unique_node_id(); | $id = celerity_generate_unique_node_id(); | ||||
} | } | ||||
if (!$this->placeholder) { | if (!$this->placeholder) { | ||||
$this->placeholder = $this->getDefaultPlaceholder(); | $this->placeholder = $this->getDefaultPlaceholder(); | ||||
} | } | ||||
$template = new AphrontTokenizerTemplateView(); | $template = new AphrontTokenizerTemplateView(); | ||||
$template->setName($name); | $template->setName($name); | ||||
$template->setID($id); | $template->setID($id); | ||||
$template->setValue($values); | $template->setValue($values); | ||||
$username = null; | |||||
if ($this->user) { | |||||
$username = $this->user->getUsername(); | |||||
} | |||||
if (!$this->disableBehavior) { | if (!$this->disableBehavior) { | ||||
Javelin::initBehavior('aphront-basic-tokenizer', array( | Javelin::initBehavior('aphront-basic-tokenizer', array( | ||||
'id' => $id, | 'id' => $id, | ||||
'src' => $this->datasource, | 'src' => $this->datasource, | ||||
'value' => mpull($values, 'getFullName', 'getPHID'), | 'value' => mpull($values, 'getFullName', 'getPHID'), | ||||
'icons' => mpull($values, 'getTypeIcon', 'getPHID'), | 'icons' => mpull($values, 'getTypeIcon', 'getPHID'), | ||||
'limit' => $this->limit, | 'limit' => $this->limit, | ||||
'username' => $username, | 'username' => $this->user->getUsername(), | ||||
'placeholder' => $this->placeholder, | 'placeholder' => $this->placeholder, | ||||
)); | )); | ||||
} | } | ||||
return $template->render(); | return $template->render(); | ||||
} | } | ||||
private function getDefaultPlaceholder() { | private function getDefaultPlaceholder() { | ||||
Show All 31 Lines |