[name]
attributes of your inputs. How does Rails assign the input data to the correct objects?Change the movie form so it no longer shows blank showtime fields for adding a new showtime. Instead there should be a button Add showtime that reveals a new blank showtime form.
The user can click on Add showtime as often as they like, always producing one more showtime form.
Implementation hint
- Render a single blank showtime form.
- A JavaScript component finds the blank form and hides it as a template for future showtimes.
- Clicking on Add showtime will copy the hidden template element, adjust
[name]
and[id]
attributes and append it to the DOM.
Package the Add showtime functionality as a generic JavaScript component so we can reuse it in other nested forms. For this to work the component must not contain any code or names specific to movies or the movie form.
Test that the component is reusable by allowing to add an actor's roles from within the actor form:
Name: [Al Porciono ]
Birthday: [1940-04-25 ]
ROLES:
+---------------------+-------------------------+------------+
| Movie | Character | |
+---------------------+-------------------------+------------|
| [The God Father v ] | [Michael Corleone ] | [ ] Remove |
| [Scarface v ] | [Tony montana ] | [ ] Remove |
| [Heat v ] | [Vincent Hanna ] | [ ] Remove |
|---------------------+-------------------------+------------+
| [Add role] |
+------------------------------------------------------------+
[ SAVE ]
Add a birthday
field to the Actor model and a character
field to the Role model if you haven't already.
You do not need to implement authorization for the nested roles table. It is OK to create roles for any movie, even though you may not have write access to that movie.