Formwidget Hotspots on map

Hi guys!

I’m working on a Hotspots on Map FormWidget. I have the functional version ready, but I want to get advice on how you would solve the image of the map. Now I statically add the path to the image from the theme assets.

map:
        label: Hospital area 
        type: hotspot
        mode: spot
        maxItems: 3        
        imagePath: 'assets/images/area-hospital.jpg'

I am considering how to do it better so that the client can change the image without going to the Editor section.

Hotspots in the picture, those animated red points

Maybe i have of one way, but I want to get some advice.
Do you have any ideas?

use mediafinder instead, or fileupload

(zdravim snipi)
yes, I thought that I would make a model setting with mediafinder and create a twig function that would return the path to the area for working in twig

1 Like

Hey @mcore,

One idea is to make the form widget depend on an attachOne relation defined on the model.

Then save the image to this relation, here is how you can set the relation as the image

$model->avatar = (new File)->fromFile('/path/to/somefile.jpg');

$model->avatar = (new File)->fromData('Some content', 'sometext.txt');

$model->avatar = (new File)->fromUrl('https://example.tld/path/to/avatar.jpg');