Ajax upload with Goodnews

Hi all, i am building a form for a swimming association.
The idea is to use Goodnews (thankyou @gadgetto) to annually send emails to old members to renew their subscription with the necessary documents.
Two documents need to be uploaded, identified, and stored to user profile. (photo + another pdf file)
I am trying to implement this with AjaxUpload (thankyou @jako).

here are the simplified calls:
[[!GoodNewsUpdateProfile?
&validate= email:email:required, gdprcheck:required
&groupsOnly=1
&postHooks=AjaxUpload2Formit,Formit2AjaxUpload
&ajaxuploadUid=photo
&ajaxuploadTarget=components/mxnsubscribed/images/user/
&gdprcheck.vTextRequired=You need to agree to our Terms and Conditions and Privacy Policy.
]]

[[!AjaxUpload?
&uid=photo
&placeholderPrefix=``
&maxFiles=1
&acceptedFileTypes=image/jpeg,image/gif,image/png,image/webp
]]

and if i use the second Ajaxupload :
[[!AjaxUpload?
&uid=certmed
&maxFiles=1
&acceptedFileTypes=image/jpeg,image/gif,image/png,image/webp
]]

Can upload two files, with two AjaxUpload calls, these are uploaded to the temp location, successfully transferred to the storing location and the temp ones are deleted.

Unfortunately, the photo field is updated with an array value.
i added two lines to write to modx log in AjaxUpload2FormitHook.php to try to see what is happening.


Environment
MODX 3.1.2, AjaxUpload 2.0.4, GoodNews 2.0.0-alpha2 (yes i know)
Local system - Laragon 6.0, php-8.2.19, MySQL 8.0.30

I’m currently trying to AjaxUpload2Formit into Goodnews preHooks, (which is were i would think it ought to be).
At the moment i’m getting error :
Uncaught Error: Call to a member function loadMultiple() on null in …core\components\goodnews\src\Controllers\Subscription\UpdateProfile.php:282

I’m not really familiar with GoodNews (and its code base), but it looks like there is a bug in the code and $this->preHooks never gets set before it is used on line 282.

Try changing line 281

to this instead

$this->preHooks = $this->subscription->loadHooks('preHooks');

and see if that helps (to get rid of this error message).

Hi halftrainedharry, thanks for your answer and your amazing help on this forum. And your videos.
Bravo, It worked a treat. Thank you very much.
I have the setup working now, i’ll publish my findings tomorrow after having clead up a little

File a bug report or submit a PR for GoodNews, too! GitHub - gadgetto/GoodNews: An integrated group and newsletter mailing system for MODX Revolution CMF