public function addControl($param_name, AphrontFormControl $control)
 {
     $celerity_id = celerity_generate_unique_node_id();
     $control->setID($celerity_id);
     $this->dynamics[$param_name] = $celerity_id;
     return $this;
 }
Esempio n. 2
0
 public function addControl(AphrontFormControl $control)
 {
     $name = $control->getName();
     if (!strlen($name)) {
         throw new Exception(pht('Form control has no name!'));
     }
     if (isset($this->controls[$name])) {
         throw new Exception(pht("Form page contains duplicate control with name '%s'!", $name));
     }
     $this->controls[$name] = $control;
     $this->content[] = $control;
     $control->setFormPage($this);
     return $this;
 }
 public function getValue()
 {
     if (!parent::getValue()) {
         $this->setValue($this->formatTime(time(), 'Y-m-d'));
     }
     return parent::getValue();
 }
 public function getLabel()
 {
     // TODO: This is a bit funky and still rendering a few pixels of padding
     // on the form, but there's currently no way to get a control to only emit
     // hidden inputs. Clean this up eventually.
     if ($this->getIsInvisible()) {
         return null;
     }
     return parent::getLabel();
 }
 public function setValue($epoch)
 {
     $result = parent::setValue($epoch);
     if ($epoch === null) {
         return $result;
     }
     $readable = $this->formatTime($epoch, 'Y!m!d!g:i A');
     $readable = explode('!', $readable, 4);
     $this->valueYear = $readable[0];
     $this->valueMonth = $readable[1];
     $this->valueDay = $readable[2];
     $this->valueTime = $readable[3];
     return $result;
 }
 public function setValue($epoch)
 {
     if ($epoch instanceof AphrontFormDateControlValue) {
         $this->continueOnInvalidDate = true;
         $this->valueDate = $epoch->getValueDate();
         $this->valueTime = $epoch->getValueTime();
         $this->allowNull = $epoch->getOptional();
         $this->isDisabled = $epoch->isDisabled();
         return parent::setValue($epoch->getEpoch());
     }
     $result = parent::setValue($epoch);
     if ($epoch === null) {
         return $result;
     }
     $readable = $this->formatTime($epoch, 'Y!m!d!' . $this->getTimeFormat());
     $readable = explode('!', $readable, 4);
     $year = $readable[0];
     $month = $readable[1];
     $day = $readable[2];
     $this->valueDate = $month . '/' . $day . '/' . $year;
     $this->valueTime = $readable[3];
     return $result;
 }
 public function readValueFromRequest(AphrontRequest $request)
 {
     // See note in readValueFromDictionary().
     $this->setSpacePHID($request->getStr('spacePHID'));
     return parent::readValueFromRequest($request);
 }