public function loadValuesFromObject(IStorableObject $object) {
$this->objectId = $object->getObjectID();
+ if ($this->attachmentData !== null) {
+ // updated attachment handler with object id
+ $this->attachmentField->attachmentHandler(
+ new AttachmentHandler(
+ $this->attachmentData['objectType'],
+ $this->getObjectId(),
+ '.',
+ $this->attachmentData['parentObjectID']
+ )
+ );
+ }
+
return parent::loadValuesFromObject($object);
}
* @return WysiwygAttachmentFormField
*/
public function attachmentHandler(AttachmentHandler $attachmentHandler = null) {
- if ($this->attachmentHandler === null && $attachmentHandler !== null) {
- $tmpHash = StringUtil::getRandomID();
- if ($this->getDocument()->isAjax()) {
- $sessionTmpHash = WCF::getSession()->getVar('__wcfAttachmentTmpHash');
- if ($sessionTmpHash !== null) {
- $tmpHash = $sessionTmpHash;
-
- WCF::getSession()->unregister('__wcfAttachmentTmpHash');
+ if ($attachmentHandler !== null) {
+ if ($this->attachmentHandler === null) {
+ $tmpHash = StringUtil::getRandomID();
+ if ($this->getDocument()->isAjax()) {
+ $sessionTmpHash = WCF::getSession()->getVar('__wcfAttachmentTmpHash');
+ if ($sessionTmpHash !== null) {
+ $tmpHash = $sessionTmpHash;
+
+ WCF::getSession()->unregister('__wcfAttachmentTmpHash');
+ }
}
+
+ $attachmentHandler->setTmpHashes([$tmpHash]);
+ }
+ else {
+ // preserve temporary hashes
+ $attachmentHandler->setTmpHashes($this->attachmentHandler->getTmpHashes());
}
-
- $attachmentHandler->setTmpHashes([$tmpHash]);
}
$this->attachmentHandler = $attachmentHandler;