hyperactiveform 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +35 -1
- data/docs/HyperActiveForm/Base.html +884 -0
- data/docs/HyperActiveForm/CancelFormSubmit.html +124 -0
- data/docs/HyperActiveForm/FormDidNotSubmitError.html +124 -0
- data/docs/HyperActiveForm/Generators/InstallGenerator.html +199 -0
- data/docs/HyperActiveForm/Generators.html +115 -0
- data/docs/HyperActiveForm.html +135 -0
- data/docs/_index.html +182 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/file.README.html +271 -0
- data/docs/file_list.html +59 -0
- data/docs/frames.html +22 -0
- data/docs/index.html +271 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +126 -0
- data/docs/top-level-namespace.html +110 -0
- data/examples/basic.md +85 -0
- data/lib/generators/form/form_generator.rb +9 -0
- data/lib/generators/form/templates/form.rb +2 -0
- data/lib/{hyper_active_form/generators.rb → generators/hyper_active_form/install/install_generator.rb} +0 -2
- data/lib/generators/rspec/form_generator.rb +11 -0
- data/lib/generators/rspec/templates/form_spec.rb +5 -0
- data/lib/generators/test_unit/form_generator.rb +11 -0
- data/lib/generators/test_unit/templates/form_test.rb +7 -0
- data/lib/hyper_active_form/base.rb +43 -5
- data/lib/hyper_active_form/version.rb +1 -1
- data/lib/hyper_active_form.rb +0 -1
- metadata +44 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c05e1cc748050b5a735f9f2fc3944427e5a3618b8083fa8ab9e3667a8d9f5f9a
|
4
|
+
data.tar.gz: e990037c9b3fcbcb5f2e68790c486f1a11bc541bb2680d2a312fa9a8336ca5e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56384a8814889a64eb844f60c9eb5eb22335d0143d83a2e2f9dcf662090ce44d9d794bdc632a4a2d672ed07c510718d63bed04e597ec657ca40ac1ec5be66fa4
|
7
|
+
data.tar.gz: 9cf4cb7e27b70e97687f19f5f860df6529e925d741c7f42d87c0c28b05a953bffcfeddbc2c72ef172b25af3ab79bc43d641d01d9718bfbbd1bba79a1b902a0b6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.0] - 2024-12-22
|
4
|
+
- Add generators (`rails generate form foo`) ([#2](https://github.com/Intrepidd/hyperactiveform/pull/2) by [@tchiadeu](https://github.com/tchiadeu))
|
5
|
+
|
6
|
+
## [0.2.0] - 2024-12-14
|
7
|
+
- Add callbacks for `assign_form_attributes` and `submit`
|
8
|
+
- Change behavior of `assign_form_attributes`/`submit` to use the default value or nil if no value is provided, rather than keeping the value from `setup`
|
9
|
+
|
3
10
|
## [0.1.0] - 2024-11-30
|
4
11
|
|
5
12
|
- Initial release
|
data/README.md
CHANGED
@@ -22,10 +22,20 @@ And then execute:
|
|
22
22
|
|
23
23
|
Run the install generator:
|
24
24
|
|
25
|
-
$ rails generate
|
25
|
+
$ rails generate hyper_active_form:install
|
26
26
|
|
27
27
|
this will create an `ApplicationForm` class in your app/forms directory. You can use it as a base class for your form objects.
|
28
28
|
|
29
|
+
## Generators
|
30
|
+
|
31
|
+
You can [generate](https://guides.rubyonrails.org/configuring.html#configuring-generators) a form and its tests with the following command:
|
32
|
+
|
33
|
+
```
|
34
|
+
$ rails generate form FooBar
|
35
|
+
```
|
36
|
+
|
37
|
+
This will create the `FooBarForm`
|
38
|
+
|
29
39
|
## Usage
|
30
40
|
|
31
41
|
Here is an example of an `HyperActiveForm` form object:
|
@@ -211,3 +221,27 @@ class UsersController < ApplicationController
|
|
211
221
|
@users = @form.results
|
212
222
|
end
|
213
223
|
end
|
224
|
+
```
|
225
|
+
|
226
|
+
## Callbacks
|
227
|
+
|
228
|
+
HyperActiveForm provides callbacks for `assign_form_attributes` and `submit`.
|
229
|
+
|
230
|
+
You can use these callbacks to run code before or after assigning the form attributes or before or after submitting the form.
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
class ProfileForm < ApplicationForm
|
234
|
+
# ...
|
235
|
+
|
236
|
+
before_submit :do_something_before_submit
|
237
|
+
before_assign_form_attributes :do_something_before_assign_form_attributes
|
238
|
+
|
239
|
+
def do_something_before_submit
|
240
|
+
# Do something before submitting the form
|
241
|
+
end
|
242
|
+
|
243
|
+
def do_something_before_assign_form_attributes
|
244
|
+
# Do something before assigning the form attributes
|
245
|
+
end
|
246
|
+
end
|
247
|
+
```
|