POC #22510 -- Reworked opting out from a base class form fields. #2615

Closed
wants to merge 2 commits into
from

Projects

None yet

3 participants

@loic
Member
loic commented Apr 29, 2014

WIP, not ready for merge!

@loic loic POC #22510 -- Reworked opting out from a base class form fields.
Using standard inheritance shadowing to opt out from a field
turned out problematic.

When a field is called `media`, it would be automatically shadowed
because of the monkeypatching from MediaDefiningClass.

When a field has the same name as a method, overloading the method
in a subclass would shadow the field.

Ref #8620, #19617.
2bb47ac
@loic loic changed the title from POC #22510 -- Reworked opting out from a base class form field. to POC #22510 -- Reworked opting out from a base class form fields. Apr 29, 2014
@apollo13
Member

Shadow_fields should at least be on meta to not clutter the form namespace any more

@loic
Member
loic commented Apr 29, 2014

We don't have Meta on Form though, only ModelForm. The form namespace already has base_fields, declared_fields, fields, it doesn't shock me to also have shadow_fields.

The form metaclass could also remove it from the class in order not to pollute the final class attrs, but then that would remove the ability to shadow fields from a simple mixin (although that'd be consistent with how simple mixins can't declare fields).

@loic
Member
loic commented Apr 29, 2014

Added another commit which makes the implementation logic of shadowed_fields very similar to the one of declared_fields.

@loic
Member
loic commented Apr 29, 2014

As a side-note, I'm not sure "shadow/shadowing" is the right term here, after all, field overloading (which forms also support) is also a "shadowing", yet it's not what this feature is about.

@timgraham
Member

Superseded by #2706.

@timgraham timgraham closed this May 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment