MarkusH / django-osm-field

Home Page:http://markush.github.io/django-osm-field

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't work in formsets

blag opened this issue · comments

commented

This is the HTML generated by OSMField when it's in a formset:

<input class="form-control osmfield osmfield-input" data-lat-field="latitude" data-lon-field="longitude" id="id_times-1-location" name="times-1-location" placeholder="Location" prefix="times-1" title="" type="text">
<!--          These are used to target other inputs ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<script type="application/javascript">$(function(){$("#id_times-1-location").osmfield();});</script>
<input id="id_times-1-latitude" name="times-1-latitude" type="hidden">
<!--   ^^^^^^^^^^^^^^^^^^^^^^^^ should target this -->
<input id="id_times-1-longitude" name="times-1-longitude" type="hidden">
<!--   ^^^^^^^^^^^^^^^^^^^^^^^^ should target this -->

As you can see, data-lat-field refers to #latitude, but there's no #latitude id on the page, there's an id_times-1-latitude id, which is what it should be targeting.

There needs to be a way to add the form's prefix attribute to the data-lat-field and data-lon-field attributes of the OSMField.