Answer the question
In order to leave comments, you need to log in
How to display the button correctly?
There is a Product model, with a form to create. How to display products for order, with the condition that the client can order only one product from one category? I think it is necessary to apply a radio button, but how to make a check on a simple form? Maybe a different implementation is needed, who knows? I am writing with slim gem.
= simple_form_for [store, store.products.build] do |f|
= f.input :name, required: false, label: false, placeholder: "Create name to new product"
= f.input :description, required: false, label: false, placeholder: "Description to new product"
br
= f.input :product_image, as: :attachment, direct: true, presigned: true, label: false, input_html: { class: 'my_class' }
br
= f.input :price, required: false, label: false, placeholder: "Price", input_html: { class: 'my_class' }
br
= f.input :category, required: false, as: :radio_buttons, label: false, collection: , label_method: :second, value_method: :first
br
= f.button :submit
create_table "products", force: :cascade do |t|
t.string "name"
t.text "description"
t.integer "reserve_quantity", default: 1, null: false
t.float "price"
t.bigint "store_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "product_image_id"
t.string "category"
t.index ["store_id"], name: "index_products_on_store_id"
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question