/**
  * Sets the value and validates it
  *
  * @param mixed $value
  * @return bool value was set successfully validated
  */
 protected function setVal($value)
 {
     if (!$this->column) {
         $value = '';
     } else {
         $validator = new ValueValidator();
         $this->error = !$validator->validateValue($this->column, $value);
         if ($this->error) {
             foreach ($validator->getErrors() as $error) {
                 msg(hsc($error), -1);
             }
         }
     }
     if ($value === array() || $value === '') {
         if (!isset($this->opt['optional'])) {
             $this->error = true;
             msg(sprintf($this->getLang('e_required'), hsc($this->opt['label'])), -1);
         }
     }
     $this->opt['value'] = $value;
     return !$this->error;
 }
 public function validateField(AbstractBaseType $type, $label, &$data)
 {
     return parent::validateField($type, $label, $data);
 }
 /**
  * Save the data posted by the inline editor
  */
 protected function inline_save()
 {
     global $INPUT;
     // check preconditions
     if (!$this->initFromInput()) {
         throw new StructException('inline save error: init');
     }
     self::checkCSRF();
     if (!$this->schemadata->getSchema()->isLookup()) {
         $this->checkPage();
     }
     if (!$this->schemadata->getSchema()->isEditable()) {
         throw new StructException('inline save error: no permission for schema');
     }
     // validate
     $value = $INPUT->param('entry');
     $validator = new ValueValidator();
     if (!$validator->validateValue($this->column, $value)) {
         throw new StructException(join("\n", $validator->getErrors()));
     }
     // current data
     $tosave = $this->schemadata->getDataArray();
     $tosave[$this->column->getLabel()] = $value;
     // save
     if ($this->schemadata->getSchema()->isLookup()) {
         $revision = 0;
     } else {
         $revision = helper_plugin_struct::createPageRevision($this->pid, 'inline edit');
     }
     $this->schemadata->setTimestamp($revision);
     try {
         if (!$this->schemadata->saveData($tosave)) {
             throw new StructException('saving failed');
         }
     } finally {
         // unlock (unlocking a non-existing file is okay,
         // so we don't check if it's a lookup here
         unlock($this->pid);
     }
     // reinit then render
     $this->initFromInput();
     $value = $this->schemadata->getDataColumn($this->column);
     $R = new Doku_Renderer_xhtml();
     $value->render($R, 'xhtml');
     // FIXME use configured default renderer
     echo $R->doc;
 }