开发者

Creating helper in rails 3

I am trying to transform the following sniped into a helper:

<%= f.autocomplete_field :profissao_nome,
                autocomplete_profissao_nome_pacientes_path,
 开发者_C百科               :value => (@item.profissao.nome if @item.profissao),
                :id_element => "#paciente_profissao_id", :class => 'element text search-modal'%>
            <%= f.text_field :profissao_id, :type => "text" %>
            <%= link_to "", search_profissaos_path, :class=>"iframe", :anchorDescription => "paciente_profissao_nome", :anchorId => "paciente_profissao_id" %>

but, all my tries fails. Even if I get the same html output, the behavior of "id_element" does not works.

def lookup_field(object_name, method, source, options ={})

    autocomplete_field(object_name, method, source, options) + "\n" +
    text_field(object_name, "religiao_id", {:type => "text"})  + "\n" +
    link_to("", eval("search_religiaos_path"), :anchorDescription=>object_name.to_s+"_religiao_nome", :anchorId=>object_name.to_s+"_religiao_id", :class => "iframe")  end
  end


Make sure you pass in the form builder object, f, to your method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜