pombreda / formalchemy

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

FieldRenderer .value vs. .raw_value for .render_readonly() #157

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When binding to post-back data:
  fsb = fs.bind(model_instance,data=request.POST)

It would seem that FieldRenderer.render() and .render_readonly() are returning 
different results. 

While .render() returns the field bound to the POST data, .render_readonly() 
seems to return the DB session value.

 Is this intended or do I have something mistaken?

I made the following update in my devel lib:

fields.py: Line 221 [ FieldRenderer.render_readonly() ]
---value = self.raw_value
+++value = self.value

And now .render_readonly() is returning the bound POST data.

Thanks for any feedback/info on this.

Original issue reported on code.google.com by nick.stu...@gmail.com on 7 Dec 2010 at 7:47

GoogleCodeExporter commented 9 years ago
I've tried your solution and saw that this break some test.

The reason is a bit obvious but I guess that when your field is a relation the 
relation value is not well handled and the field is empty.

It's better to rebind your form after saving it:

fs.rebind(fs.model, data=None); fs.render_readonly = True

I guess this should do the trick.

Original comment by gael.pas...@gmail.com on 16 Jan 2011 at 2:32

GoogleCodeExporter commented 9 years ago

Original comment by gael.pas...@gmail.com on 25 Mar 2011 at 12:43