activeadmin中的collection_select [英] collection_select within activeadmin

查看:76
本文介绍了activeadmin中的collection_select的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Activeadmin为has_many&创建一个漂亮的下拉菜单。所属组织。但是由于我需要编辑表单,因此将这些内容删除了。

Activeadmin creates a nice dropdown menu for has_many & belongs_to associations. But since I needed to edit my form, these things where deleted.

在我的原始表单中,我使用了:

In my original form, I used:

<%= f.label :artist_id %><br />
<%= collection_select(:work, :artist_id, Artist.all, :id, :name) %>

但这在我的admin / works.rb中不起作用。我在那创建的表单是:

But this does not work in my admin/works.rb. The form i have created there is:

    ActiveAdmin.register Work do
  form do |f|
        f.inputs "Details" do
          f.input :title
          f.input :exhibition_id
          f.input :artist_id
          f.input :photo
        end

        f.buttons
      end
end

如何在我的管理表单中创建类似的效果?

How can i create a similiar effect in my admin form?

推荐答案

Activeadmin使用Formtastic,这是我如何解决的方法:

Activeadmin uses Formtastic and this is how i solved it:

f.input :artist, :as => :select, :multiple => false, :input_html => { :size => 1 }

这篇关于activeadmin中的collection_select的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆