Nara Hari
2006-Jun-19 13:23 UTC
[Rails] text_field_with_auto_complete doesn|t work in edit/show view
Hi, I am using the autocomplete for text field with ''Scriptaculous'' and it works perfectly fine in "new" action. All the examples I see are only for the "new" action. But doesn''t default to the selected value/text in "edit/show" action? Is this possible or should I write custom code for "edit/show" action? Thanks, Hari -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Jun-19 13:48 UTC
[Rails] text_field_with_auto_complete doesn|t work in edit/show view
On Monday, June 19, 2006, at 3:22 PM, Nara Hari wrote:>Hi, > >I am using the autocomplete for text field with ''Scriptaculous'' and it >works perfectly fine in "new" action. > >All the examples I see are only for the "new" action. > >But doesn''t default to the selected value/text in "edit/show" action? Is >this possible or should I write custom code for "edit/show" action? > >Thanks, Hari > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsI''ve used it recently for edit views as well as new views with no issues. _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Nara Hari
2006-Jun-19 14:03 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
Kevin Olbrich wrote: Hi Kevin, Thanks for the reply. My code in "_form.html" looks like: <p><label for="reseller_state_id">Reseller Location</label><br/> <%= text_field_with_auto_complete :state, :state_name, {:size => 50} %></p> and in controller: auto_complete_for :state, :state_name In my ''reseller'' model I have an ID for the state and the ID is to be looked up from the "state" model. This code works fine in "new" action but doesn''t get the default state name in edit/show action? How does your model look like? Is the usage any different? Thanks,Hari> On Monday, June 19, 2006, at 3:22 PM, Nara Hari wrote: >>Thanks, Hari >> >>-- >>Posted via http://www.ruby-forum.com/. >>_______________________________________________ >>Rails mailing list >>Rails@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails > > I''ve used it recently for edit views as well as new views with no > issues. > > _Kevin-- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Jun-19 14:11 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
Nara Hari wrote:> My code in "_form.html" looks like: > <p><label for="reseller_state_id">Reseller Location</label><br/> > <%= text_field_with_auto_complete :state, :state_name, {:size => 50} > %></p> > > and in controller: > auto_complete_for :state, :state_nameIs the field on state called ''state_name'' or ''name'' ? Alan -- Posted via http://www.ruby-forum.com/.
Nara Hari
2006-Jun-19 14:23 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
state_name _Hari Alan Francis wrote:> Nara Hari wrote: > >> My code in "_form.html" looks like: >> <p><label for="reseller_state_id">Reseller Location</label><br/> >> <%= text_field_with_auto_complete :state, :state_name, {:size => 50} >> %></p> >> >> and in controller: >> auto_complete_for :state, :state_name > > Is the field on state called ''state_name'' or ''name'' ? > > Alan-- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Jun-19 14:47 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
Nara Hari wrote:> state_name > > _Hari >It could be that somethings getting confused there as, ISTR, the form field names use underscores to separate the object and field. How hard (or easy) would it be for you to rename the column as ''name'' or ''statename'' and retry ? Would there be much code to change ? Note this is all supposition, so if it''s a lot of work, don''t do it as I''ve zero guarantee of success :-) Alan -- Posted via http://www.ruby-forum.com/.
Nara Hari
2006-Jun-19 15:11 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
It was not a big deal to change the column name, but I still couldn''t get it working in show/edit view. How does your model & code for "_form.rhtml" looks like? Thanks. _Hari -- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Jun-19 15:33 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
Nara Hari wrote:> It was not a big deal to change the column name, but I still couldn''t > get it working in show/edit view. > > How does your model & code for "_form.rhtml" looks like? > > Thanks. > > _HariSorry Hari, I don''t have one, I''m working from memory while here at my (Java) day job. A. -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Jun-19 17:06 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
On Monday, June 19, 2006, at 4:03 PM, Nara Hari wrote:>Kevin Olbrich wrote: > >Hi Kevin, > >Thanks for the reply. > >My code in "_form.html" looks like: ><p><label for="reseller_state_id">Reseller Location</label><br/> ><%= text_field_with_auto_complete :state, :state_name, {:size => 50} >%></p> > >and in controller: > auto_complete_for :state, :state_name > >In my ''reseller'' model I have an ID for the state and the ID is to be >looked up from the "state" model. > >This code works fine in "new" action but doesn''t get the default state >name in edit/show action? > >How does your model look like? Is the usage any different? > >Thanks,Hari > >What do you get when you do this... <%= debug(@state) %> in your _form.rhtml file and call it with the ''new'' or ''show'' actions? _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Nara Hari
2006-Jun-19 20:46 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
Kevin Olbrich wrote:> On Monday, June 19, 2006, at 4:03 PM, Nara Hari wrote: > > What do you get when you do this... > > <%= debug(@state) %> > in your _form.rhtml file > > and call it with the ''new'' or ''show'' actions? > > > _KevinWhen I add the debug statement I get nothing, only "---". What information should this bring...even in "new" it shows only the hyphens. _Hari -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Jun-19 22:32 UTC
[Rails] Re: text_field_with_auto_complete doesn|t work in edit/show
On Monday, June 19, 2006, at 10:46 PM, Nara Hari wrote:>Kevin Olbrich wrote: >> On Monday, June 19, 2006, at 4:03 PM, Nara Hari wrote: >> >> What do you get when you do this... >> >> <%= debug(@state) %> >> in your _form.rhtml file >> >> and call it with the ''new'' or ''show'' actions? >> >> >> _Kevin > >When I add the debug statement I get nothing, only "---". What >information should this bring...even in "new" it shows only the hyphens. > >_Hari > > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsYour @state variable is probably not being set properly by the controller. This would explain why the autocomplete is failing. load a default or create a blank one. _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.