jeudi 17 octobre 2019

Rails Change common id of simple_form_for

I want to change form common name in rendering side

_from.html.haml
..
= f.simple_fields_for Image.new do |form|
      = render 'avatar_fields', f: form
..

_avatar_fields.html.haml
..
     = f.hidden_field :imageable_type
..

This is rendering like

<input id="product_image_imageable_type" name="product[image][imageable_type]" type="hidden">

But i want to render like this

<input id="product_logo_attributes_imageable_type" name="product[logo_attributes][imageable_type]" type="hidden">

I don't want to edit my '_avatar_fields.html.haml' screen. Because it's common html.

Any suggestion please..?

Aucun commentaire:

Enregistrer un commentaire