gpt4 book ai didi

ruby-on-rails - 在 Active Admin 中更改只读输入文本

转载 作者:行者123 更新时间:2023-12-05 01:45:35 27 4
gpt4 key购买 nike

我有一个代码有影响力的协会。我想在代码表单中将影响者用户名显示为只读。

现在我在做:

form do |f|
f.inputs 'Code' do
f.input :influencer, input_html: { readonly: true, disabled: true }, as: :string if !f.object.new_record?

但是我明白了,我想要影响者的名字或用户名。

I need a field displayed. Not the object.

想法?

最佳答案

我最终在代码模型中添加了这一行

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?

关于ruby-on-rails - 在 Active Admin 中更改只读输入文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41144136/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com