Closed (duplicate)
Project:
Address Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Feb 2011 at 14:46 UTC
Updated:
8 Dec 2014 at 12:30 UTC
Jump to comment: Most recent
Comments
Comment #1
xlyz commentedtry hook_form_alter.
Comment #2
michaelfavia commented@kriboogh This module seems to be implemented with the desire to keep things as simple as possible (which i agree with). Unfortunately this principle might be slightly at odds with the increasing prominence of the module as the default address storage mechanism for drupal 7. The diversity of address formats may also play into the consideration not to allow this as the setting might have to be stored per country allowed (this is just an educated guess).
As Geofield and geocoder mature and this module develops into the defacto standard there will undoubtedly be more need for features of this type (the name field on the widget also has an issue relating to this).
Adding your feature would be simple and i could use it myself (currently form_altering) but i think that it might be outside of scope for the module maintainers use case as he uses it for Drupal Commerce which obviously needs full addresses to ship packages, etc.
@ryan any feedback welcome. Ill post a patch/drop the issue with a little direction.
Comment #3
damien tournoud commentedThe
-reloadedbranch has been merged. It comes with many refactored things, including new required fields. Feedback welcome, as I think we might need to improve this again.Comment #4
marcus_w commented@damien Which version should I use to see the required fields? I'm using 1.0-beta1, but can't find the settings. Can't find it in -dev as well..
Comment #5
damien tournoud commentedI'm sorry, but we are not going to support per-field required settings in the UI. You can easily implement an address format plugin for this (see the examples in the module code).
Comment #6
seanrDamien, the problem with your suggestion is that is a per-country implementation. I really cannot reasonably be expected to copy all of the possible country formats (I'm dealing with an international site) and modify every one of them to just to add a required setting to specific fields (in my case, organisation). Is there any particular reason why this cannot be done through the addressfield module itself? I can implement hook_form_alter for sure (although the addressfield form structure is rather opaque), but really, shouldn't this be an option within the UI?
Comment #7
seanrchanging version
Comment #8
perarnet commentedI agree this is needed, for example thoroughfare is a value that is not used on all adresses in my country. To have to programmatically change the settings for every implementation of addressfield is really a setback for ease of use.
Comment #9
that0n3guy commentedIts easy to "un-require" stuff in a module. Here is an example of un-requiring the street address and zip:
Comment #10
magicmyth commentedSorry to bump this but IMHO the suggestion above is not the best work around to this as its all too easy to find the form structure has changed for multiple reasons (e.g. another module already made an alteration). A more reliable place to make such an alteration is with hook_field_widget_WIDGET_TYPE_form_alter() like so:
This way you do not need to be concerned with things like translations, deltas and other low level parts.
As for the topic. I'd like to put forward a use case for controlling which fields are mandatory as I've just had a client who is listing events on their site. These events can be out in places without post codes (many are in fields, on moors). This is a common enough use case and expecting an administrator to dive into the code is quite user unfriendly. I know there is a desire to keep from cluttering the UI but many parts are already configurable (optional country specific, name, organisation) and we are talking about something only a site administrator deals with and only on rare occasions. I don't see it as causing much hassle in using the UI if the required state of the UI is configurable.
Comment #11
seanrFantastic advice, magicmyth. I wonder how hard it would be to wrap this up in a contrib module that allows configurability on a per-field, per-node basis. I might take a whack at that.
Comment #12
rootworkI'd love to see this as an add-on contrib module, if per-field support isn't possible within the module itself. Do report back seanr!
Comment #13
iwant2fly commentedI am also seconding a request for this seanr. I would be happy to bug test and or possibly throw a little $$ your way.
Comment #14
seanrStill on my radar, guys, just been slammed lately.
Comment #15
Kristina Katalinic commentedI am having a similar problem here. Don't need Address1 and Address 2 fields at all.
I was trying to get rid of them using example.module and plugin file address .inc but that lead to errors.
If anyone has a solution for this I'd really appreciate it
Comment #16
matthijsI think the patch in #1263316: Configurable non-empty value conditions can be used to solve this issue?
Comment #17
System Lord commentedAny movement with this, seanr?
Comment #18
System Lord commented#10 will this work in profile2 ? Instead of: 'your_node_type' what would I use to reference this in a profile form field for addressfield?
This will be a nice feature as I as need 5 required street fields, 2 optional, and 2 that I don't even need to display.
Comment #19
yekezei commentedYou can also use https://drupal.org/project/field_validation and set individual fields as required
Comment #20
rootworkThanks! That's definitely helpful, although I think this kind of functionality is pretty fundamental and should be core to addressfield. The cases in which some but not all parts of the address are required are quite frequent.
Just my two cents.
Comment #21
System Lord commented+1
Comment #22
held69 commentedWithout succes i tried to make my postal_code field required using with #9:
$form['field_adres']['und'][0]['locality_block']['postal_code'][#required]=True;However using dpm my postal_field mentioned:
#required (Boolean) TRUEStrange thing is that i can hide my postal_code field with:
hide($form['field_adres']['und'][0]['locality_block']['postal_code']);Also setting the address field (including all the fields) required is no problem:
$form['field_addressfield']['und'][0]['#required'] = TRUE;Help appreciated
thanks
Comment #23
bojanz commentedClosing as duplicate of #1263316: Configurable non-empty value conditions.