If you wanted it to just be a constant value that you set, why not set
it after form submission in a before_save callback or something? After
all, a malicious client can still submit a value for that property.

What if you just want to set the field to a certain default value but
then want to give the user the option to change it? Let's say you were
suggesting a value. It just seems to me that there will be more cases
where developers will intend something like this by setting the value
on a new form than cases where they intend that to be a kind of
constant.

I'm all about surprising people sometimes. But there is something to
the principle of least surprise. Non-nil or not attribute protected
and not equal to the db default doesn't scream hidden field to me. It
took me a couple of hours to step through the dryml code to figure out
what was going on. At the very least, we'll document it somewhere on
the wiki.

On Nov 27, 7:30 am, Tom Locke <[EMAIL PROTECTED]> wrote:
> > if you do something like this in your controller:
>
> > m = Model.new
> > m.foo = "non-default-value"
>
> > You basically get #foo as a hidden field on your form. Probably not
> > what you expected.
>
> My take is that if you're setting a field, then you want that field to  
> be set, both on the "new" page and later in the DB when you save the  
> thing. That's why the hiddens are added. *Maybe* they should be off by  
> default, if that's less surprising. Then again, if you never surprise  
> people, you can never move forwards.
>
> > Plus, on my browser, if I DO have a #foo form field
> > later on, any value in there doesn't get submitted.
>
> It is supposed to automatically remove the hidden if you have a  
> corresponding input. Are you rendering the form field using the  
> regular <input> tag without a name attribute?
>
> > At the least, should the val.nil? be val.blank?
>
> Hmmm that's a bit tricky. I'm inclined to leave it as is, as it's been  
> working for me, but I'm happy to look at examples where val.blank?  
> would work better.
>
> Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to