在 Active Admin 中更改只读输入文本
Changing a readonly input text in Active Admin
我有一个代码有影响力的协会。
我想在代码表单中将影响者用户名显示为只读。
现在我在做:
form do |f|
f.inputs 'Code' do
f.input :influencer, input_html: { readonly: true, disabled: true }, as: :string if !f.object.new_record?
但是我明白了,我想要影响者的名字或用户名。
想法?
我最终在代码模型中添加了这一行
delegate :username, to: :influencer, prefix: true, allow_nil: true
然后是以下形式:
f.input :influencer_username,
label: 'Influencer',
input_html: { readonly: true, disabled: true },
as: :string unless f.object.new_record?
我有一个代码有影响力的协会。 我想在代码表单中将影响者用户名显示为只读。
现在我在做:
form do |f|
f.inputs 'Code' do
f.input :influencer, input_html: { readonly: true, disabled: true }, as: :string if !f.object.new_record?
但是我明白了,我想要影响者的名字或用户名。
想法?
我最终在代码模型中添加了这一行
delegate :username, to: :influencer, prefix: true, allow_nil: true
然后是以下形式:
f.input :influencer_username,
label: 'Influencer',
input_html: { readonly: true, disabled: true },
as: :string unless f.object.new_record?