Michal Zugec napsal(a): > ref: refs/heads/network > commit da9fb271b2b1b5b2885702cc7a2ca1261da29664 > Author: Michal Zugec <[email protected]> > Date: Thu Sep 24 19:23:44 2009 +0200 > > for configuration mode use combo box (bnc#540229) > --- > .../network/app/controllers/network_controller.rb | 8 +++++++- > plugins/network/app/views/network/index.html.erb | 2 +- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/plugins/network/app/controllers/network_controller.rb > b/plugins/network/app/controllers/network_controller.rb > index 29c2f74..65c8f46 100644 > --- a/plugins/network/app/controllers/network_controller.rb > +++ b/plugins/network/app/controllers/network_controller.rb > @@ -56,7 +56,13 @@ class NetworkController < ApplicationController > @nameservers = dns.nameservers > @searchdomains = dns.searches > @default_route = rt.via > - > + #FIXME: this is ugly and keys are duplicated, but otherwise seems it > doesn't work ^^^^^^ If you properly read how options for select works you understand why it is. You can read it here -> http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M001627 > + @conf_modes = [["",""], ["static","static"], ["dhcp", "dhcp"]] so you can change it to hash version or use array, but translate it ;) @conf_modes = {""=>"", _("static") =>"static", _("dhcp") => "dhcp"} # disclaimer - writed without try, so maybe it can be buggy, just for demonstration ;) > + # if unknown item, just add it into list > + found = false > + @conf_modes.each {|a| found=true if a[0] == @conf_mode} > + @conf_modes << [...@conf_mode, @conf_mode] if !found change to: @conf_mod...@conf_mode]=@conf_mode unless @conf_modes.has_value(@conf_mode) #warning, unknown mode is not translated, at least log it > + > end > > > diff --git a/plugins/network/app/views/network/index.html.erb > b/plugins/network/app/views/network/index.html.erb > index 50a20b1..104d2e4 100644 > --- a/plugins/network/app/views/network/index.html.erb > +++ b/plugins/network/app/views/network/index.html.erb > @@ -34,7 +34,7 @@ > </tr> > <tr> > <td class="first" width="120"><strong><%=_("Configuration > Mode")%></strong></td> > - <td class="last"><%=text_field_tag :conf_mode, @conf_mode, :disabled => > disabled %></td> > + <td class="last"><%= select_tag(:conf_mode, > options_for_select(@conf_modes, @conf_mode), :disabled => disabled)%></td> > </tr> > <tr> > <td class="first" width="120"><strong><%=_("IP Address")%></strong></td>
If you have any question, you can ask me tomorrow. Josef -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
