You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm having a problem where I would like a single form partial as the source of truth for a given resource - in this example an Article. I also have a BlogArticle model that has a has_one relationship to Article via a polymorphic field and essentially contains additional metadata for an Article. I intend to have multiple different "Article types" and would like to use the Article partial within both the Article resource's own AA page and the nested has_one form of BlogArticle and any other similar models.
I'd hoped to be able to do something along the lines of:
Create a partial that contains just the inputs for the given resource:
_article_form.arb
f.input :author
f.input :title
BlogArticles.rb:
f.has_many :article, allow_destroy: false, class: 'has_one' do |a|
render 'admin/article_form', f: a
end
Articles.rb:
f.inputs do
render 'admin/article_form'
end
The form renders fine on the Article AA resource page but rendering the partial within the f.has_many on BlogArticle simply doesn't render the inputs.
I have a feeling it's because the partial doesn't actually contain an entire form element but rather just inputs? I don't see how else I can match the expected AA syntax when trying to re-use the partial in both the standard resource form and a has_one context.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I'm having a problem where I would like a single form partial as the source of truth for a given resource - in this example an
Article
. I also have aBlogArticle
model that has ahas_one
relationship toArticle
via a polymorphic field and essentially contains additional metadata for anArticle
. I intend to have multiple different "Article types" and would like to use the Article partial within both theArticle
resource's own AA page and the nestedhas_one
form ofBlogArticle
and any other similar models.I'd hoped to be able to do something along the lines of:
Create a partial that contains just the inputs for the given resource:
_article_form.arb
BlogArticles.rb:
Articles.rb:
The form renders fine on the
Article
AA resource page but rendering the partial within thef.has_many
onBlogArticle
simply doesn't render the inputs.I have a feeling it's because the partial doesn't actually contain an entire form element but rather just inputs? I don't see how else I can match the expected AA syntax when trying to re-use the partial in both the standard resource form and a
has_one
context.Is there any way to do what I'm proposing?
Beta Was this translation helpful? Give feedback.
All reactions