Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File upload via frontend is not saved in the event anymore after Calendar update #336

Open
jurgenkrol opened this issue Oct 16, 2024 · 7 comments
Assignees
Labels
issue Something isn't working correctly

Comments

@jurgenkrol
Copy link

When I create an event via the frontend (with action calendar/events/save-event) fields with file uploads are not saved as an asset in the event.
The form tag contains the attribute enctype="multipart/form-data" and "Allow Guest Access on Front End" is enabled. Of course, the field is also defined as an asset field in the field layout.

This problem arose after an upgrade of Calendar from version 3.3.21 to version 5.0.10 (Craft was also updated from version 3.9.13 to 4.12.6.1). Before that it worked fine.

Craft & Plugin Info:

  • Craft Version: 4.12.6.1
  • Calendar Version: 5.0.10
  • Calendar Edition: Pro
  • Fresh Install or Upgrade: Upgrade
@jurgenkrol jurgenkrol added the issue Something isn't working correctly label Oct 16, 2024
@jurgenkrol jurgenkrol changed the title File upload via frontend is not saved in the event anymore after Calemdar update File upload via frontend is not saved in the event anymore after Calendar update Oct 16, 2024
@shayneg0
Copy link

Craft Version: 4.12.5
Calendar Version: 5.0.8

Noticed that the issue is in 5.0.7, since we downgraded to 5.0.6 and it was working.

@kjmartens kjmartens self-assigned this Oct 18, 2024
@kjmartens
Copy link
Contributor

Sorry for the trouble you're experiencing @jurgenkrol and @shayneg0.

When I try this on my end using the demo templates included with Calendar, it seems to work without issue. Can you share what your template code looks like? 🙂

@jurgenkrol
Copy link
Author

Here is a stripped down version of the code:

<form method="post" accept-charset="UTF-8" id="evenenent-formulier" enctype="multipart/form-data">
    {{ csrfInput() }}
    <input type="hidden" name="action" value="calendar/events/save-event">
    {{ redirectInput('event-submitted') }}
    
    <input type="hidden" name="calendarEvent[calendarId]" value="2">
    <input type="hidden" name="enabled" value="">
    

    <input type="text" name="title" required value="{{ event is defined?event.title }}">

    <input type="text" name="fields[city]" required value="">
    <input type="text" name="fields[street]" required value="">
    <input type="text" name="fields[housenumber]" required value="">
    <input type="text" name="fields[zipcode]" required value="">
    <input type="email" name="fields[eventEmailAddress]" placeholder="" value="}">

    <textarea name="fields[description]" required>{{ event is defined?event.description }}</textarea>

    <input type="file" id="image-upload"  name="fields[image][]" class="upload" accept=".gif, .jpeg, .jpg, .png, .webp" required>

    {# value of event_builder_data is set by JS and is saved correctly in the event #}
    <input id="event-builder-data" type="hidden" name="event_builder_data" value='{"dates":{"start":,"end":},"allDay":false,"interval":1,"multiDay":false,"repeats":false,"freq":"DAILY","byDayInterval":0,"byDay":["MO"],"byMonthDay":[29],"byMonth":[6],"endRepeat":{"type":"forever","date":,"count":1},"selectDates":[],"exceptions":[]}'>

    <button class="button red" type="submit">Register event</button>
</form>

Everything is saved fine except the image. Replacing name="fields[image][]" with name="fields[image]" doesn't make a difference either.

As pointed out by @shayneg0 it still works in version 5.0.6 and below.

I think all the changes in version 5.0.7 in packages/plugin/src/Elements/Event.php regarding UploadFile introduced the issue.

@kjmartens
Copy link
Contributor

Thanks @jurgenkrol.

Can you try changing this line:
<input type="hidden" name="action" value="calendar/events/save-event">

to this:
<input type="hidden" name="action" value="calendar/legacy-events/save-event" />

And let me know if this resolves the issue? 🙂

@jurgenkrol
Copy link
Author

Replacing "calendar/events/save-event" with "calendar/legacy-events/save-event" is what I had already tried. In that situation too, the file is not uploaded and not saved in the event.

@phillipsandoveracademy
Copy link

We are experiencing the same issue with Calendar 5.0.7+. At the time of testing, we are running Craft CMS 4.13.6. For our users, we have had a front-end form for many years on our Athletic site, which is only accessible by logging into Craft CMS. In upgrading the site, the form works with Calendar 5.0.6, but not 5.0.7+. Our users update a calendar event with win/loss info and can upload an image from the athletic event with the front-end form. Please let us know if you need any specific info. Is there a fix?

@kjmartens
Copy link
Contributor

I'm very sorry for the delay and the trouble @jurgenkrol, @shayneg0 and @phillipsandoveracademy.

I will have a developer check into this shortly. I have a hunch about what it might be caused by. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue Something isn't working correctly
Development

No branches or pull requests

5 participants