/** * @param form_persistentdocument_mail $document * @param Integer $parentNodeId Parent node ID where to save the document (optionnal => can be null !). * @throws form_ReplyToFieldAlreadyExistsException * @return void */ protected function preSave($document, $parentNodeId = null) { if ($document->getMultiline()) { $document->setValidators('emails:true'); } else { $document->setValidators('email:true'); } if ($parentNodeId !== NULL) { $form = DocumentHelper::getDocumentInstance($parentNodeId); } else { $form = $this->getFormOf($document); } if ($form === null) { if (Framework::isWarnEnabled()) { Framework::warn(__METHOD__ . ' the mail field document (' . $document->__toString() . ')is not in a form'); } } else { if ($document->getUseAsReply()) { $oldReplyField = form_BaseFormService::getInstance()->getReplyToField($form); if ($oldReplyField !== null && $oldReplyField !== $document) { Framework::error(__METHOD__ . ' Old reply field :' . $oldReplyField->__toString()); throw new form_ReplyToFieldAlreadyExistsException(f_Locale::translate('&modules.form.bo.errors.Mail-field-for-replyto-exists')); } } } parent::preSave($document, $parentNodeId); }
/** * @param form_persistentdocument_mail $field * @param string $value * @return string */ private static function returnTextFieldHtml($field, $value) { // build required attributes $attributes = array(); $attributes['maxlength'] = $field->getMaxlength(); $attributes['value'] = $value; $attributes['title'] = $field->getHelpText(); if ($field->getMultiline()) { $attributes['cols'] = $field->getCols(); $attributes['rows'] = $field->getRows(); return self::multilineTextBox($field->getFieldName(), $field->getId(), $value, $attributes); } else { $attributes['size'] = $field->getCols(); $attributes['autocorrect'] = $field->getDisableAutocorrect() ? 'off' : 'on'; $attributes['autocapitalize'] = $field->getDisableAutocapitalize() ? 'off' : 'on'; $attributes['autocomplete'] = $field->getDisableAutocomplete() ? 'off' : 'on'; return self::textBox($field->getFieldName(), $field->getId(), $value, $attributes); } }