This is a bit of a weird issue. Might be a bug, but I could be messing something up. I have a form that displays fields from a data table row in an alert popup. Everything is working as it should except the image box.
Uploading a new image works fine, but when saving the form without updating the image the image in the data table somehow gets messed up. Here is a gif showing that the uploaded image is working fine.
Here is a gif showing that saving the data without updating the image kills the image. To be clear, it is still in the data table, but it is 0 bytes in size.
The image is displayed on the form via a server call. Server code:
@anvil.server.callable
def get_coupon_info(coupon_id):
coupon_info = app_tables.coupons.get(id=coupon_id)
return coupon_info
Client code:
coupon_details = anvil.server.call('get_coupon_info', coupon_id)
# many other elements being assigned up here
self.image.source = coupon_details['image']
# other elements being assigned down here
When the save button is clicked the following functions calls the server (I know the positional arguments are insane):
if anvil.alert(ec, buttons=[("Save", True, "primary"), ("Back", False)],large=True):
response = anvil.server.call('update_coupon',
self.item['id'],
ec.title.text,
ec.short_description.text,
ec.long_description.text,
ec.category.selected_value,
ec.location.text,
ec.original_price.text,
ec.price.text,
ec.restriction.text,
ec.image.source,
ec.start_date.date,
ec.end_date.date,
ec.phone.text,
ec.address.text,
ec.special_instructions.text,
ec.coordinates.text
)
self.raise_event("x-close-alert")
n = Notification(response)
n.show()
Then on the server the data is being saved with this function. For troubleshooting I removed any other error handling.
@anvil.server.callable
@anvil.tables.in_transaction
def update_coupon(coupon_id, title, short_description, long_description, category, location, original_price, price, restriction, image, start_date, end_date, phone, address, special_instructions, coordinates):
coupon = app_tables.coupons.get(id = int(coupon_id))
coupon['title'] = title
coupon['short_description'] = short_description
coupon['long_description'] = long_description
coupon['category'] = category
coupon['location'] = location
coupon['original_price'] = original_price
coupon['price'] = price
coupon['restriction'] = restriction
coupon['image'] = image
coupon['start'] = start_date
coupon['end'] = end_date
coupon['phone'] = phone
coupon['address'] = address
coupon['special_instructions'] = special_instructions
coupon['coordinates'] = coordinates
# write success response
response = 'Coupon Updated Successfully'
return response
Thanks in advance!