Closed fcontinitorres closed 5 years ago
Hi @fcontinitorres, congratulastions on your first issue! 🍾 👍 👏 👏 👏
I would love to help you! However right now, your question is not entirely clear to me. Could you please elaborate what is going wrong?
So to take this further:
Sorry for indentation, the code works correctly for nested form without modal (you don't need fix it)
I tried make it in so many different ways that a I can't tell whats going wrong or types of error I had, so I preferred to come my project back to the begin that it is almost exactly like your example code on main page. I don't have modal yet, just nested form.
I was thinking if you could provide an example of a modal with a Cocoon form
Sorry for my bad english
It should just work, so if you check the documentation of bootstrap (depending on which version you are using), you can just include the form. I am not quite sure I understand what the specific problem is that you are having.
For example in bootstrap 3 it should be something like
.modal.fade#my-modal-form
.modal-dialog
.modal-content
.modal-header
%button.close{:type => "button", :'data-dismiss' => "modal", :'aria-hidden' => "true"}
×
%h4.modal-title This is the title for my form
.modal-body
= simple_form_for @project do |f|
# ...
... but this is a bit weird, because you are in cocoon issues and asking help (??) how to render a form in bootstrap? Surely you already got this far? So this could not be your actual question, right?
Please note that while I understand that stackoverflow.com might not always be welcoming, imho that is the better place for these kind of questions. A lot of people are eager to help beginners.
But note, also on stackoverflow it is a lot easier if you ask a more specific/clear question. Something like: this is the code, this is what I am trying to achieve, please help.
Sorry, I didn't not specify my problem correctly,
I'm try to create a modal on Task (no on Project), something like when I click on
= link_to_add_association 'add task', f, :tasks , it should open a bootstrap modal, after save, show on view _form of Project the description attribute of task, maybe on dataTable, whatever.
I imagene it should't be done with = link_to_add_association 'add task', f, :tasks, and I don't have any idea how to do.
I tried to create this Task without link_to_add_association and make a bootstrap modal with a remote call on button, but it's not works. I had a token problem, so imagined that should had a easier way to do that with Cocoon.
Sorry for make you lost your time don't being specific, I'm noob on RoR and make questions to >.<
Sorry for the late reply, but if I understand correctly what you are asking, it is not cocoon you want to use. Cocoon builds a large form, containing all nested items and saves them in one go when submitting the form to the server.
Opening a modal form when adding a new nested item feels more suited to some remote js calls. E.g.
/tasks/new?project_id=XX
This is not what cocoon does or allows.
Closed due to inactivity.
Hi, I'm pretty new on ruby on rails and I'm trying to create a nested fields in a bootstrap modal. I search for a days a solution for it and failed. Everything I found was too complex or incomplete answer Could you make a simple exemple using it? I have a simple project using Cocoon like the exemple on main page.
= simple_form_for @project do |f| = f.input :name = f.input :description %h3 Tasks
tasks
= f.submit
Something like that and works correctly Ty for attention.