pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

FieldSet.configure() can not be called multiple times, without resetting the rendered fields #84

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'd like to call fs.configure(include=[...]) a first time, and later, based
on conditions, call fs.configure(options=[modifiedfield1.required()]) and
not override the first call with included fields.

Original issue reported on code.google.com by wackysa...@gmail.com on 29 Mar 2009 at 5:43

GoogleCodeExporter commented 9 years ago
This fixes the issue.

Original comment by wackysa...@gmail.com on 29 Mar 2009 at 5:44

Attachments:

GoogleCodeExporter commented 9 years ago
here is my commit log:

Author: Alexandre Bourget <alex@bourget.cc>  2009-03-29 01:42:25
Committer: Alexandre Bourget <alex@bourget.cc>  2009-03-29 01:42:25
Parent: 7fe6603a65eddf1128137507a3b50d1871915ded (Fix issue #83 - Pass a 
context to
validators to allow multi-field validation)
Branch: master
Follows: 
Precedes: 

    Make sure we can call .configure() multiple times, with consistent and
predictable results.

    Removed some documentation to ModelRenderer for params it didn't have.
    NOTE: there is duplication with documentation in docs/forms.txt from ModelRenderer.

    It is now possible to call a fs.configure(options=[fs.field1.required()]) that
    will simply replace the `field1` from the options instead of the current
    _render_fields Field element.

    Also, save focus=True/False and readonly=True/False between calls to configure()
    on FieldSet.
    Same for global_validator on AbstractFieldSet and FieldSet.

Original comment by wackysa...@gmail.com on 29 Mar 2009 at 5:45

GoogleCodeExporter commented 9 years ago
Perhaps for consistency we could make configure() behave like bind() -- 
returning a
copy with the changes made, but the original object would be unchanged.

Thoughts?

Original comment by jbel...@gmail.com on 31 Mar 2009 at 3:22

GoogleCodeExporter commented 9 years ago
Issue 86 has been merged into this issue.

Original comment by jbel...@gmail.com on 31 Mar 2009 at 3:22

GoogleCodeExporter commented 9 years ago
... the downside is doing this would break the hell out of existing code.

maybe we'd have to call that 2.0 :)

Original comment by jbel...@gmail.com on 31 Mar 2009 at 3:23

GoogleCodeExporter commented 9 years ago
Currently, calling configure() only has an unpredictable behavior.  Tweaking it 
so 
that it does something intuitive probably won't break any code, since people 
just 
*aren't* calling it twice.

I recall implementing this feature in a git branch somewhere on Github:

http://github.com/abourget/formalchemy-
abourget/commit/93bbf515a2c0c152bb73551969191b2ca908c9e5

I would greatly appreciate that be in!

Original comment by bourget....@gmail.com on 5 Mar 2010 at 6:34

GoogleCodeExporter commented 9 years ago
As usual, if you can assume that this wont break tests I don't have problems. 
Can you 
add this to your hg clone ? I dont really know how to extract a git changeset.

Original comment by gael.pas...@gmail.com on 5 Mar 2010 at 9:12

GoogleCodeExporter commented 9 years ago
I think the only problem left here is that calling configure() twice give 
unknown 
behavior, without throwing an error.

All the necessity of configuring a field a second time is mostly done with, 
with the 
.insert_after, .insert, and .set() methods on Fields.  That fills my needs in 
all 
cases.

For other cases, I now use functions to generate new fieldsets, so 
reconfiguring 
isn't much of a problem.

Maybe we could just raise an error in case of a double-call ?

Original comment by bourget....@gmail.com on 14 Mar 2010 at 1:05

GoogleCodeExporter commented 9 years ago
agree. also you can now use fs.copy() + fs.append/insert/etc. to build a 
similare 
fieldset

Original comment by gael.pas...@gmail.com on 14 Mar 2010 at 11:10