0

After a form is saved I need to concatenate together the {{proposalCompanyName}} handle with the {{proposalFileUpload}} handle so that the saved filename in the Assets folder is proposalCompanyName.proposalFileUpload.extension. This is the event code in my module/plugin I've figured so far:

Event::on(Entry::class, Entry::EVENT_AFTER_SAVE, function(Event $event) {

            if (Craft::$app->request->isSiteRequest)
            {
                $formEntryElement = $event->sender;
                $userSubmittedName = Craft::$app->fields->getFieldByHandle('proposalCompanyName');
                $userSubmittedFilename = Craft::$app->fields->getFieldByHandle('proposalFileUpload');
                $concatFilename = $userSubmittedName.$userSubmittedFilename;

                $formEntryElement->set($concatFilename => $userSubmittedFilename);
            }

        });

Thank you for any input or criticisms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.