[Form] Allow to inherit translation domain for all elements of a form #3649

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

uwej711 commented Mar 20, 2012

Currently I can set a translation_domain on each field of a form, but there is no simple way to do it once for a complete form. This change passes on the translation_domain from the form to its elements if translation_domain is not explicitly set on a field.

Member

stof commented Apr 3, 2012

@bschussek what do you think about this way to do this ? I personally find it a bit hacky to add the option in the factory (and potentially broken if someone register a type which does not inherit from field btw) but I don't have a better idea

@uwej711 your branch needs to be rebased as tests have been moved

uwej711 added some commits Mar 20, 2012

@uwej711 uwej711 Allow to inherit translation domain for all elements of a form
Currently I can set a translation_domain on each field of a form, but there is no simple way to do it once for a complete form. This change passes on the translation_domain form the form to its elements if translation_domain is not explicitly set on a field
ccb823c
@uwej711 uwej711 Tests have been moved 1f2196e
Contributor

uwej711 commented Apr 4, 2012

@stof rebase is done (had to force the push ...)

What is confusing about the form component is that there are two hierarchies one that builds up the form from the fields and one that is about types inheriting from other types. There are always parents involved and it is hard for the beginner to figure out what is what.

Currently I think there is no generic mechanism to propagate settings from the form (now I mean the first mentioned hierarchy) to the form elements. Maybe there are other cases where this would be useful, maybe the "error_bubbling" when I don't want to have the error messages at the field level.

Member

webmozart commented Apr 5, 2012

@uwej711 You are right about the confusion. But we cannot solve this right now, unfortunately.

Apart from that, this solution doesn't make sense. The parent of a form could change later, in this case the translation domain wouldn't get updated. Could you open a ticket and close this PR unless you find a better solution?

Contributor

uwej711 commented Apr 5, 2012

@bschussek can you point me to a simple example of a forms parent changing later to find a solution that works for that case as well?

Member

webmozart commented Apr 5, 2012

@uwej711 Just pass a Form instance to the add() method of another Form instance

Contributor

uwej711 commented Apr 5, 2012

I had a look at the code again and basically there is no chance to place this somewhere, when you want to take care of @bschussek 's concern about adding parents later: even when it is placed somewhere in the view building step I could add another view as a parent later and there will be the same issue as mentioned above. I don't see another solution that could take care of that issue.

Contributor

uwej711 commented Apr 5, 2012

Doing this via buildViewBottomUp in my custom form type will not really work nicely as I can no longer find out, whether the translation_domain was set somewhere explicitly or was just the default when the form was created :-(

Contributor

uwej711 commented Apr 10, 2012

I think it could be handled in the buildViewBottomUp. Maybe it will be easier based on #3789

Owner

fabpot commented Apr 11, 2012

I have opened a ticket #3872

fabpot closed this Apr 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment