Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using the lat/long widget, and when I choose to make it a "required field", it tries to validate the "default value" setting on saving the edit form and gives me the "required" error message. Presumably there is a way to tell validation that the default value isn't actually an instance of the form needing validated?
Comment | File | Size | Author |
---|---|---|---|
#6 | geofield-cannot_mark_field_as_required-1946058-6.patch | 2.47 KB | DuaelFr |
Comments
Comment #1
dpw CreditAttribution: dpw commented+1 making the field "required" in design view seems to require a default value to be added. I'm using the OpenLayers widget and Geofield 7.x-2.0-alpha2+7-dev (2013-Apr-06).
Comment #2
bechtold CreditAttribution: bechtold commented+1 using 7.x-2.0-alpha2+9-dev
If you enter a default value, the validation is ok, but the default value is not saved :-)
Comment #3
geodaniel CreditAttribution: geodaniel commentedThis is an issue in 2.0 as well.
Comment #4
Breakerandi CreditAttribution: Breakerandi commentedAny news on this? I have the issue still with the latest 2.1 version!!!
Comment #5
tisteegz CreditAttribution: tisteegz commentedI am also experiencing this issue and I can confirm that when I entered in default values the validation worked but the values weren't saved. Which is somewhat of an issue if anyone does want default values.
Comment #6
DuaelFrHere are two independant patches that fixes both issues.
I updated the priority to Major because not being able to set a field as required without giving it a default value (which is never displayed again) prevents users to use the field as they need to.
Comment #7
gge CreditAttribution: gge commentedI had a problem where the default values were not displayed on add node form and after applying #6 patches everything works now. The patches couldn't be applied automatically using Netbeans but I applied them manually.
Thank you!
Comment #8
das-peter CreditAttribution: das-peter commentedI had a similar or basically the same issue in the new openlayers / geofield integration.
The way I handled this was using
'#limit_validation_errors'
to completely disable the validation and the use$form_state['input']
instead$form_state['values']
to access the values for geocoding.Not sure of this works for all scenarios - but as for now it's part of openlayers ;)
Related openlayers commit: http://cgit.drupalcode.org/openlayers/commit/?id=a380422
Comment #9
GaëlGI can confirm that #6 fixes the bug. Thank you DuaelFr!
Comment #10
MissterX CreditAttribution: MissterX as a volunteer commentedGeofield version 7.x-2.3
#6, patch geofield-cannot_mark_field_as_required-1946058-6.patch
Confirmed as working.
Comment #11
brockfanning CreditAttribution: brockfanning commentedAnother report that one of the patches in #6, geofield-cannot_mark_field_as_required-1946058-6.patch works to fix the bug that Geofields cannot be set as required.
I wonder if the fact that there are 2 patches here might be confusing the issue and delaying this getting committed. I would vote for committing geofield-cannot_mark_field_as_required-1946058-6.patch. After applying that patch, I don't see any problems with either setting a Geofield as required, or giving it a default value.
In fact, I'll take the liberty of hiding the extra patch, but feel free to reverse that if I'm missing something.