2

I have a content type with a geofield. I'm using an Openlayers Map as the input Widget. The map allows the user to place a marker and it populates the geofield with the lon/lat coordinate. In some cases, however, it would be preferred to input the lon/lat manually as opposed to using the map.

How would you provide an option in the node edit form to dynamically switch the display widget for the geofield from the Openlayers map to lon/lat, or from lon/lat to a map?

2

The use case you describe is specific in nature, but the question you actually asked in the title is more general purpose. I’m answering the question in the title.

To the best of my knowledge, there is not at present an Input Widget Switcher module for Drupal 7 or earlier, but there really needs to be. There are similar modules such as Display Suite for altering the displayed output of a node, including using different display formatters (example: showing the same date field as a short date format in a Teaser and as a long date format in a full node display), but nothing analogous for node input form widgets.

Drupal 8 has the underlying structure needed to implement something like this, known as Form Modes (basically the input form equivalent of View Modes such as Full vs. Teaser, which Display Suite builds on). But while there is a UI for creating them, there is not at present to the best of my knowledge an ability to use them or switch between Form Modes in core.

That said, the Form Mode Control module for D8 does seem to provide this ability. It allows switching between Form Modes based on Role or Permission and on Node (or Entity) Creation vs. Modification (for instance, on Creation the Widget for a GeoField might be Lat/Long with HTML5 GPS Geolocation enabled, but on Modification switch to a different Form Mode that uses, say, OpenLayers Map Widget so that the already-existing location marker can be moved on a map).

There’s also the similar Form Mode Manager module (also D8 only) that works a bit differently, but it’s only in Alpha at the time of this writing, while Form Mode Control is in Release Candidate 2 and thus better for production sites.

| improve this answer | |
0

I'm not sure you are looking for the exact same thing but have a look here https://drupal.org/sandbox/GwenMahe/2055375 I am still developing it, so if you notice some bug it's because it's not perfect yet !

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.