XF 2.2 Two textfields with attachments

Robert9

Well-known member
I have a usual item with title, textfield, attachments.
Now i have added a second textfield, added a second attachmenthandler ...

The result now is:

Form one shows textfield 1 and attachupload; everything fine.

Form two shows textfield 2 and attachupload; the attachment can be uploaded and will be inserted.
But it is also shown under textfield 1.

You cant help me here without code.
But you may can tell me:

Would it be possible to have two text fields for one item and both with different attachments?

What I could not find until now is the right place, where the field is connected with content_type1 or content_type2.
 
Status now:

Upload an image in form two for field two adds a row to xf_attachment with content_type2.
Means that the problem is while/after saving, when this row should change from unassociated =1, id=0, temphash exists to the final row with an id.

After saving, the row is finished, but with content_type1 instead of 2.
 
Code:
        $attachmentRepo = $this->repository('XF:Attachment');
        $imageAttachData = $attachmentRepo->getEditorData('item_image2', $item ?: null);

        $viewParams = [
            'item' => $item,
            'imageAttachData' => $imageAttachData
        ];
        
        ...

Then I call the form and the form knows that we work with item_image2,
but where the replacement is done for XF:Attachment?

I have added a new class /Attachment/ItemImage2, but in this class is no info about the content_type.
 
Found it in a preparer, makes sense

Code:
        if ($this->imageAttachmentHash)
        {
            $this->associateAttachments($this->imageAttachmentHash, 'item_product_image', $context, true);
        }
 
Top Bottom