Hi, The documentation doesn''t make it clear why both file_field and file_field_tag are both useful. What is the reason for having two instead of just one of these? Thanks, Peter
On 15.1.2006, at 18.42, Peter Michaux wrote:> Hi, > > The documentation doesn''t make it clear why both file_field and > file_field_tag are both useful. What is the reason for having two > instead of just one of these?The former is meant for (normal) situations where you have an object +method pair at hand. The latter is a more low-level method with which you have to do more handiwork. It''s useful in cases where you don''t have a matching object and method for the field (a search form comes to mind). If you take a closer look at the api, you''ll notice that similar methods exist for all form field types, like text_field and text_field_tag. //jarkko -- Jarkko Laine http://jlaine.net http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2363 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060115/884f1fff/smime.bin
It looks like file_field is the one that is more low-level with more options. On 1/15/06, Jarkko Laine <jarkko@jlaine.net> wrote:> On 15.1.2006, at 18.42, Peter Michaux wrote: > > > Hi, > > > > The documentation doesn''t make it clear why both file_field and > > file_field_tag are both useful. What is the reason for having two > > instead of just one of these? > > The former is meant for (normal) situations where you have an object > +method pair at hand. The latter is a more low-level method with > which you have to do more handiwork. It''s useful in cases where you > don''t have a matching object and method for the field (a search form > comes to mind). > > If you take a closer look at the api, you''ll notice that similar > methods exist for all form field types, like text_field and > text_field_tag. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://odesign.fi > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >
On 15.1.2006, at 19.19, Peter Michaux wrote:> It looks like file_field is the one that is more low-level with > more options.I won''t go into debating which is more low-level, but file_field assumes that you give it an object and a method and bakes you an input field from those, with id and name attributes set automatically. You don''t have to specify anything else. file_field_tag, however, doesn''t know anything about objects. So in effect, the two following would be roughly equivalent: <%= file_field "person", "photo" %> <%= file_field_tag "person[photo]", :id => "person_photo" %> //jarkko> > On 1/15/06, Jarkko Laine <jarkko@jlaine.net> wrote: >> On 15.1.2006, at 18.42, Peter Michaux wrote: >> >>> Hi, >>> >>> The documentation doesn''t make it clear why both file_field and >>> file_field_tag are both useful. What is the reason for having two >>> instead of just one of these? >> >> The former is meant for (normal) situations where you have an object >> +method pair at hand. The latter is a more low-level method with >> which you have to do more handiwork. It''s useful in cases where you >> don''t have a matching object and method for the field (a search form >> comes to mind). >> >> If you take a closer look at the api, you''ll notice that similar >> methods exist for all form field types, like text_field and >> text_field_tag. >> >> //jarkko >> >> -- >> Jarkko Laine >> http://jlaine.net >> http://odesign.fi >> >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2363 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060115/775ce4a1/smime.bin