Comments (6)
There is no concept like update
or create
in a form. Can you explain how you use this? I don't understand how you use a form in two different contexts. Could be a feature in the Reform::ActiveRecord
extension...
from reform.
For example on a user form, when you have a new user form; you'll want to validate the presence of password_confirmation but you obviously wouldn't want that on an update.
from reform.
How about NewUserForm
and UpdateUserForm
? I think that's what's intended with this library.
from reform.
@ivanyv That is absolutely right. However, if that makes it more convenient for people we should consider it.
from reform.
Personally I like it as is. But here's a crazy idea: rename the save
method to submit
and move any automatic save functionality to a module to be included. Then submit
calls a create
or update
method when that module is included, otherwise all it does is sync the params to the passed object.
Having the method called save
kind of threw me off at first, but that might just be me :)
from reform.
This has gone a little stale. I think that this is somewhat mitigated when a form is encapsulated within an operation.
If using dry-validations you could also build rules that only run if your form is persisted e.g.
def valid_field(value)
return true if !form.persisted? # the check passes
value > 12 # if persisted then we check further
end
I'm going to close this, but please reopen if you need. 😄
from reform.
Related Issues (20)
- Out of the box dry-validation not working HOT 1
- Error with dry-validation 1.3 HOT 5
- Reform 2.3 breaks `require 'reform/form/active_model/validations'` HOT 6
- Regression in 2.3 when adding errors in an overridden setter method
- Dynamic form fields and stack level too deep HOT 3
- Validation block option :form incorrectly memoized between tests (in different form instances?) HOT 12
- Skipped property is still passed for validation
- Calling `#name` unexpectedly … HOT 1
- populator adding just one record HOT 3
- Form returns merged errors for `collection` after validation HOT 1
- Using custom validation message adds `Base` to message
- How to validate JSON object where keys are variable and unknown? HOT 3
- Errors of nested collection are not shown. HOT 1
- `self` in default value for properties is broken when Reform 2.6 is with trailblazer-context HOT 5
- Cast strings to nil without nilify. HOT 1
- Updating record with nested ActiveStorage attachments fails HOT 13
- validation blocks with inherit: true option ignore other options HOT 3
- Problem with delegation in forms in 2.6.1 / disposable 0.6.0 HOT 26
- Destroying nested form objects HOT 1
- Using a nested form with populator. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reform.