Changeset View
Changeset View
Standalone View
Standalone View
src/view/form/AphrontFormView.php
<?php | <?php | ||||
final class AphrontFormView extends AphrontView { | final class AphrontFormView extends AphrontView { | ||||
private $action; | private $action; | ||||
private $method = 'POST'; | private $method = 'POST'; | ||||
private $header; | private $header; | ||||
private $data = array(); | private $data = array(); | ||||
private $encType; | private $encType; | ||||
private $workflow; | private $workflow; | ||||
private $id; | private $id; | ||||
private $shaded = false; | |||||
private $sigils = array(); | private $sigils = array(); | ||||
private $metadata; | private $metadata; | ||||
private $controls = array(); | private $controls = array(); | ||||
private $fullWidth = false; | private $fullWidth = false; | ||||
private $classes = array(); | |||||
public function setMetadata($metadata) { | public function setMetadata($metadata) { | ||||
$this->metadata = $metadata; | $this->metadata = $metadata; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getMetadata() { | public function getMetadata() { | ||||
return $this->metadata; | return $this->metadata; | ||||
Show All 14 Lines | public function setMethod($method) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setEncType($enc_type) { | public function setEncType($enc_type) { | ||||
$this->encType = $enc_type; | $this->encType = $enc_type; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setShaded($shaded) { | |||||
$this->shaded = $shaded; | |||||
return $this; | |||||
} | |||||
public function addHiddenInput($key, $value) { | public function addHiddenInput($key, $value) { | ||||
$this->data[$key] = $value; | $this->data[$key] = $value; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setWorkflow($workflow) { | public function setWorkflow($workflow) { | ||||
$this->workflow = $workflow; | $this->workflow = $workflow; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addSigil($sigil) { | public function addSigil($sigil) { | ||||
$this->sigils[] = $sigil; | $this->sigils[] = $sigil; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addClass($class) { | |||||
$this->classes[] = $class; | |||||
return $this; | |||||
} | |||||
public function setFullWidth($full_width) { | public function setFullWidth($full_width) { | ||||
$this->fullWidth = $full_width; | $this->fullWidth = $full_width; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getFullWidth() { | public function getFullWidth() { | ||||
return $this->fullWidth; | return $this->fullWidth; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | public function render() { | ||||
$sigils = $this->sigils; | $sigils = $this->sigils; | ||||
if ($this->workflow) { | if ($this->workflow) { | ||||
$sigils[] = 'workflow'; | $sigils[] = 'workflow'; | ||||
} | } | ||||
return phabricator_form( | return phabricator_form( | ||||
$this->getViewer(), | $this->getViewer(), | ||||
array( | array( | ||||
'class' => $this->shaded ? 'phui-form-shaded' : null, | 'class' => implode(' ', $this->classes), | ||||
'action' => $this->action, | 'action' => $this->action, | ||||
'method' => $this->method, | 'method' => $this->method, | ||||
'enctype' => $this->encType, | 'enctype' => $this->encType, | ||||
'sigil' => $sigils ? implode(' ', $sigils) : null, | 'sigil' => $sigils ? implode(' ', $sigils) : null, | ||||
'meta' => $this->metadata, | 'meta' => $this->metadata, | ||||
'id' => $this->id, | 'id' => $this->id, | ||||
), | ), | ||||
$layout->render()); | $layout->render()); | ||||
Show All 20 Lines |