commerceguys / addressing

A PHP addressing library, powered by CLDR and Google's address data.
MIT License
915 stars 133 forks source link

Rewrite the symfony/form integration #66

Open bojanz opened 7 years ago

bojanz commented 7 years ago

The old integration was removed in 8b770ffe0830f5c7626833113f27a80da6febb22. Needs to be updated for the new subdivision storage, and for Symfony 3.0. Also needs to be finished, in regards to AJAX.

The Drupal form implementation is a good one to investigate, but it won't be a 1-1 mapping cause symfony/form is a lot less flexible.

abdfork commented 7 years ago

I'm working on a PR for this, using symfony forms

abdfork commented 7 years ago

I have added support for Symfony Forms, it can use a custom translator and also, if installed, it uses symfony/translation to translate the labels of the form.

I have one problem though, Address doesn't have setters using the standard set* functions, so the Symfony property accessor used by Symfony fails. I have arguably added a magic setter here as a workaround but maybe we should add the proper setters to Address or we could leave it alone and not use a data_class in AddressType to prevent more coupling with Symfony.

Have a look at 78c70fd and we can discuss further or if you're happy with it I can prepare a PR.

I think I will also be working on a Symfony Bundle using Addressing

bojanz commented 7 years ago

Great! I'm out of town so I won't be able to look at the code for another day or two.

For the Address setter problem you want to define a custom data mapper, as described here: https://webmozart.io/blog/2015/09/09/value-objects-in-symfony-forms/ That way we keep the current value object semantics of the Address object.

abdfork commented 7 years ago

Sorry for the radio silence.

I though of that, but I don't like using a custom mapper if the entity has it's own setters and getters, specially when we have trouble just with the setters. In the end, I've created a custom propertyAccessor to use with*() here 58859f0

Let me know your thoughts.

leevigraham commented 7 years ago

Any update on the PR?

bojanz commented 7 years ago

@abdfork Sorry, I've definitely been the bottleneck for this issue. A big reason for that is because I personally don't use Symfony (Forms). Thinking about it some more, I definitely think that the form integration should live in the Symfony Bundle (which registers our repositories and formatters in the container, provides the form bits, etc). Would you be willing to create and maintain one? I could then link it from the README here.

Pointing #44 to this issue, since it was about the old form integration's inability to have translated labels. Also pointing #55, which has a reasonable feature request (allow to choose which address fields will be rendered).

Pierrmouth commented 4 years ago

Hey there Is there someone maintaining this part ? Couldn't find any other addresses bundle fine enough and I'm not able to make one by myself ...

bojanz commented 4 years ago

Looks like the bundle to follow is https://github.com/daften/addressing-bundle