/** * @param form_persistentdocument_field $document * @param Integer $parentNodeId Parent node ID where to save the document (optionnal). * @return void */ protected function preSave($document, $parentNodeId = null) { $fieldName = $document->getFieldName(); if (f_util_StringUtils::isEmpty($fieldName)) { $this->fieldNameCounter = $this->fieldNameCounter + 1; $fieldName = 'f' . time() . $this->fieldNameCounter; if (Framework::isDebugEnabled()) { Framework::debug(__METHOD__ . ' Generate FieldName: ' . $fieldName . ' for document ' . $document->__toString()); } $document->setFieldName($fieldName); } $parentDoc = $parentNodeId != null ? DocumentHelper::getDocumentInstance($parentNodeId) : $this->getParentOf($document); form_BaseformService::getInstance()->checkFieldNameAvailable($document, $parentDoc->getId()); $this->fixRequiredConstraint($document); }