/**
  * Validates a filled in field wrt. custom constraints.
  *
  * @return string (X)HTML.
  */
 protected function validateFilledInFieldCustom()
 {
     $o = '';
     if (function_exists('advfrm_custom_valid_field')) {
         $value = $this->field->getType() == 'file' ? $_FILES[$this->name] : stsl($_POST[$this->name]);
         $valid = advfrm_custom_valid_field($this->formId, $this->field->getName(), $value);
         if ($valid !== true) {
             $o .= '<li>' . $valid . '</li>' . PHP_EOL;
             Controller::focusField($this->formId, $this->name);
         }
     }
     return $o;
 }
Example #2
0
 /**
  * Returns whether a field is visible.
  *
  * @param Field $field A field.
  *
  * @return bool
  */
 protected function isFieldVisible(Field $field)
 {
     return ($field->getType() != 'hidden' || $this->showHidden) && $field->getType() != 'output';
 }
Example #3
0
 protected static function renderButtonInput(Field $field)
 {
     return sprintf('<button type="%s" name="%s" value="%s" %s>%s</button>', $field->getType(), $field->getName(), $field->getValue(), $field->getAttributes(), $field->getLabel());
 }
 /**
  * Returns whether a field is labelled.
  *
  * @param Field $field A field.
  *
  * @return bool
  */
 protected function isLabelled(Field $field)
 {
     return !in_array($field->getType(), array('checkbox', 'radio', 'hidden'));
 }
Example #5
0
 /**
  * Returns the value of the type attribute of an input element.
  *
  * @return string
  */
 protected function getInputElementType()
 {
     return in_array($this->field->getType(), array('file', 'password', 'hidden')) ? $this->field->getType() : 'text';
 }
Example #6
0
 /**
  * Change column from null to not null
  * @param Field $field
  */
 public function changeFieldToNotNullable($field)
 {
     $result = PerfORMController::getConnection()->query('select * from %n where %n is null', $field->getModel()->getTableName(), $field->getName());
     $pk = $field->getModel()->getPrimaryKey();
     foreach ($result as $row) {
         if (!is_null($value = $field->getDefaultValue())) {
         } elseif (is_callable($field->getDefaultCallback())) {
             $value = call_user_func($field->getDefaultCallback(), $row);
         } else {
             throw new Exception("Unable to set default value for field '" . $field->getName() . "'");
         }
         PerfORMController::getConnection()->query('update %n set %n = %' . $field->getType() . ' where %n = %i', $field->getModel()->getTableName(), $field->getName(), $value, $pk, $row->{$pk});
     }
     PerfORMController::getBuilder()->changeFieldsNullable($field);
     $this->updateFieldSync($field);
 }