Closed (duplicate)
Project:
Address Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Dec 2010 at 01:27 UTC
Updated:
2 May 2013 at 14:52 UTC
Jump to comment: Most recent file
Comments
Comment #1
jcarlson34 commentedThis would be a nice addition. Currently I am hacking the code to remove the name field.
Comment #2
redben commentedAbsolutely +1
Comment #3
ryan.armstrong commentedSame here, and I hate doing that, just for upgrading purposes alone, but it'll have to do for now :)
Comment #4
Scott J commentedRyan,
Are you using this http://drupal.org/project/name module?
Comment #5
ryan.armstrong commentedScott J,
That'd be the one!
Comment #6
acouch commented+1.
Attached is a patch that adds that option and updates the preprocess and templates. The maintainer may have a more elegant way to deal with the first_name / last_name but this is here for what it is worth.
(first git patch on d.o.!)
Comment #7
joelstein commented#6 works for me.
Comment #8
David D commentedI was working with this mod several months ago and ended up switching to Location in large part because of this particular issue. There are numerous instances where address fields are needed but there is no need for a name field that is attached to the address in this way. It can make for an awkward node form, for one thing, by forcing a layout that's not necessarily appropriate.
Comment #9
henrijs.seso commentedThere are two small problems.
1) patch leaves addressfield-formatter.tpl.php untouched. Shouldn't it modify default template too?
2) leaving name field empty template inserts BR tag before address
Comment #10
ronald_istos commentedWas working with this today and did a small patch similar to above that just changes the addressfield.module - however, it adds the last missing option. So now we have the range Full Name, First and Last, Name and Company, Just Company, Nothing.
Didn't touch the .tpl, will try and submit an additional patch for that. If one of the maintainers indicates if this is something they are interested in and it makes sense to work more on it will add that later on.
Comment #11
mrfelton commented+1 for this. I echo the sentiments in comment #2.
#10 seems to be working for me. Thanks.
Comment #12
Fidelix commentedWhat about hiding these?
Postal code
Neighborhood
Complement
Number
Address
Is this out of the scope of this module? In my case, I just need the city. The country will always be the same, and so will the State.
Comment #13
arrow+1 for no name field
I'm going to give that patch a try in the mean time.
Comment #14
geerlingguy commented+1 / Subscribe - Location module had almost too much customization for location fields, but at least I could hide fields I absolutely didn't need... :)
Patch in #10 needs review.
Comment #15
Mark F commentedWorks for me
Comment #16
Christopher Riley commentedQuick question....If there is an option to disable the name field won't that mess around with the the needs of the commerce module which requires this module?
I think a possible alternative would be for this module to be patched to support tokens for default values so that if we already have a first name, last name, etc field that it pulls the data in but the user can still change it.
Comment #17
michaelfavia commentedI need this as well. Ryan if you could give us a little direction on the route youd like to take as maintainer: required token support (if necessary) or something similar to the patch in #10. One of us will happily patch this up for your review.
Comment #18
seandunaway commentedI got around this by just modifying the template file and removing the line break logic.
This allowed me to hook_form_alter the form to remove the Name field to the user and still display it properly. I had to alter it anyway to adjust some labels.
I love the module, thank you for sharing!
Comment #19
michaelfavia commented@rump: while this addresses display it ignores the form collection issues which still have to be FAPi'd out of there too.
Comment #20
geerlingguy commentedClosed duplicate: #1181618: Optional Full Name.
Comment #21
elly commentedEchoing #12 - is hiding other field components, or adjusting granularity of what is collected, out of scope of this module?
I'd love to be able to limit what can be stored with this field, especially postal code, etc. I just need city, state/province & country on the sites I'd use addressfield on. I'll form_alter it if possible (is anyone doing this?), but adding the ability to specify what to collect to the field settings seems useful. I know that's getting into location module territory but I think it's useful enough to consider :)
Comment #22
seandunaway commentedYeah, I've just been altering it. I set a default value for country and let the others just stay empty.
Then I also hijacked the template file to modify its output:
Comment #23
elly commentedAwesome. Thanks for this.
Comment #24
seandunaway commentedDamien, what direction do you want to take with this? I can spend some effort on this if you let me know how you want it completed.
I think minimally we should patch the templates with conditionals so if a user doesn't input a field (name for example), there wont be broken line breaks when viewing the node.
Please advise,
Comment #25
seandunaway commentedPotential solution #983240: Suggested modification to addressfield-formatter.tpl.php.
Comment #26
wjaspers commentedsub
Comment #27
damien tournoud commentedThe
-reloadedbranch has been merged. The name and organisation fields are now completely optional.Comment #28
Fidelix commentedDamien, what about the other fields? What if I just want to collect the state, and leave the Country with a fixed value?
Comment #29
tommychrisIn that case, use a Text Field or a drop-down. So why you need this module, if you want to collect only states?
Comment #30
Fidelix commentedSo I'm able to integrate it with OpenLayers using this module features.
Comment #31
mototribe commentedsame here, just want to collect city, state, zip, country and skip the address fields
Comment #32
jcarlson34 commented@mototribe another option for you might be to use http://drupal.org/project/field_collection to build fields for the City, State, ZIP, and Country. You could also use CSS to hide the address fields.
Comment #33
webankit commentedWill be great if components of address also become optional.
Comment #34
webankit commentedCouldn't create a patch with additional files, so attaching the module.
When i tried to create a patch by reading http://drupal.org/node/1054616
$ rebase origin/7.x.1.xComment #35
webankit commentedSeparated the main address-form(country-specific) into :
Comment #36
seandunaway commented@webankit,
The remote is 7.x-1.x not 7.x.1.x.
Comment #37
webankit commentedThanks @rump
Created a patch for separate address-form components:
Comment #38
mefisto75 commentedWill this be added into core?
Comment #39
webankit commentedIt just alters the form, not the database table... I think you can safely use this.
Comment #40
mikeytown2 commented#37 does not apply cleanly to the latest dev.
Comment #41
klonosI agree that this module should behave more like Name Field and provide ways for people to create customized "presets" for both the edit form and display:
The changes should be touching only the UI - the db should should be left alone so we keep the main purpose of this module intact:
If people think this is way too much overhead, this can live as a submodule ("address_fields_manager" ??) or even in contrib if the maintainers choose to not support this.
PS: if this did get accepted, some issues could be removed from the queue as duplicates:
#1316788: Do not display country in address block if only one country option is available
#1337656: Use only one address field
#1368532: Remove address1 and address2 only use country, city, state, and zip
...more???
Comment #42
kevinquillen commentedIs there a way to render an address like:
Street
City, State, Zip
I looked at the addressfield example module, but wasn't sure if what I was looking at was the way to do it.
Comment #43
wjaspers commented@KevinQuillen, yes, its possible, using field_view_field() and passing in some display settings, but its tricky. Gotta dig up some code from a prior project if I can remember where it is.
Comment #44
fehin commentedAnyone got the patch in #37 working on the latest dev?
Comment #45
xanoWhat about we split up address data in different groups/layers (by specificity), say country > administrative area(s) > city > address > adressee (although there's a discussion to remove addressee support from this module). If layer has a default value, and so does its preceding less specific layers, its form element can be made optional or disabled. Example:
* If the country is set, it can be made optional.
* To disable the city field, the country, administrative area and the city fields need default values.
This approach ensures every stored address is usable and should exist in the real world, because even if some fields are optional, we enforce default values. We do however allow some fields to be be targeted at residents of a specific city or neighborhood, by allowing fields to be optional or hidden.
The separation in layers also allows other modules to easily use and configure address fields, even if the services they use do not know how to handle all kinds of international fields. A Dutch or Belgian service may offer international address processing, but it may not support a specific state field, simply because those countries don't have states and the service's makers never thought of how handle those for other countries. Layers allow such modules and services to tell an address field how specific an address they want, without having to know about all the little details.
Format handlers can be rewritten as well, because the addressee is one layer of specificity and whether it's an organization's or a person's name (or both), doesn't matter from an API point of view. We can rewrite form handlers as a list of layers with optional default values that can be made optional or disabled.
Comment #46
sreynen commentedThat's exactly my use case.
This validation doesn't currently exist. It's already possible for users to create address field instances with only a country value, a country and city with no state, etc. Giving administrators the ability to remove fields that can already be left empty doesn't seem to introduce any new complications for modules using those fields, since those modules already need to confirm fields contain the expected data.
Additional validation might be useful, but I think it can and should be addressed as a separate issue.
Comment #47
carl.ben commentedI've been using #34 version, and it works. Have not tried #37 since it appears not to be working.
What are the next steps for moving this forward?
Comment #48
vundmfred commentedHello,
I have downloaded your attachment addressfield.zip . It works well.
But in Germany, the postal code before the city are (e.g. 74072 Heilbronn). What can I do to ensure that the postal code comes first and then the location.
Thanks for your answer.
regards
Fred
Comment #49
Eric B. commentedThanks to rump's post, I was able to unrequire and remove the "Address 1" and "Address 2" fields from the form. Here's my example:
Comment #50
jasom commentedI assume that with "Separate Components of Address field" functionality will come also functionality for views fields that every address field will be available as view field. No I can use only whole address field in views fields.
I need display just one field country and in another field only city. I do not need address line or ZIP.
Comment #51
rszrama commentedI'm actually not sure why this issue is still alive. The original post was from the early alpha days requesting functionality that got included in the beta rewrite. It's now fully possible to have an address field that does not request any name information at all - you simply uncheck the name line handler in the field settings. It looks to me like the original request got abstracted out to make any part of the address optional, and that's the gist of the 2.x roadmap in #1829900: [meta] Address Field 2.x needs pluggable administrative areas and an actual API. I'm going to mark this a duplicate of that and link to the patch in #37 from there. It won't apply any longer and is probably not the direction we'd go, but linking it in will preserve the discussion that's taken place if necessary.