Skip to content

Commit daf17d5

Browse files
authored
improve modal generator Readme documentation (#103)
1 parent 95b87ed commit daf17d5

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/generators/rolemodel/modals/README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
* frame-missing handler (required for turbo-rails v1.4.0 and above)
99
* a very simple stimulus controller `toggle` to help with modal/panel animations.
1010

11+
## After install (Update Only)
12+
13+
1. This generator does not currently attempt to remove the old RoleModel Modal/Confirm/Panel or MakeFormsRemote javascript files or initialization code. However, that code needs to be removed for the new process to work correctly.
14+
2. Remove Rails-UJS from your project. Most likely that means running `yarn remove @rails/ujs` and then deleting the `import` and `start()` statements from application.js.
15+
3. Ensure your application layout now includes the *empty* `turbo_frame_tag`s for `modal` & `panel` as well as the new confirm partial. The generator should have done this but it may have failed if your layout is much different than expected.
16+
1117
## Turbo confirm example
1218

1319
```slim
@@ -72,7 +78,7 @@ class SomethingsController < ApplicationController
7278
end
7379
```
7480

75-
## Layout Content Slots
81+
## Modal header & footer
7682

7783
The included modal layout includes *slots* for title content & submit buttons, in addition to the main content `yield`. You may, of course remove these sections if they don't match your use-case. Otherwise, the following is an example edit template meant to be rendered in the modal layout.
7884

@@ -88,4 +94,17 @@ The included modal layout includes *slots* for title content & submit buttons, i
8894
= f.input :description
8995
```
9096

91-
__note:__ the submit button in the `new.html.slim` version of this template would be `form: dom_id(@thing)` or simply `form: 'new_thing'`. For further explanation of form Id generation, see the [polymorphic_path docs](https://api.rubyonrails.org/classes/ActionDispatch/Routing/PolymorphicRoutes.html) or simply inspect the form element in your browser.
97+
__note:__ the submit button in the `new.html.slim` version of this template would be `form: dom_id(@thing)` or simply `form: 'new_thing'`.
98+
99+
Alternatively, it's still possible to nest the `content_for` block within the form builder if you need to leverege button text generation, for example. Though you __must__ still set the `form` attribute explicitly, because the button (or `input[type='submit']` in this case) will ultimately be rendered outside of the `<form></form>` tags. e.g.
100+
101+
```slim
102+
= simple_form_for @thing do |f|
103+
= f.input :name
104+
= f.input :description
105+
106+
= content_for :modal_actions do
107+
= f.submit form: f.id
108+
```
109+
110+
For further explanation of form Id generation, see the [Record Identifier](https://api.rubyonrails.org/classes/ActionView/RecordIdentifier.html) and [polymorphic Routes](https://api.rubyonrails.org/classes/ActionDispatch/Routing/PolymorphicRoutes.html) docs, or simply inspect the form element in your browser.

0 commit comments

Comments
 (0)