Coder Social home page Coder Social logo

Comments (6)

apotonick avatar apotonick commented on September 28, 2024

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.

cj avatar cj commented on September 28, 2024

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.

ivanyv avatar ivanyv commented on September 28, 2024

How about NewUserForm and UpdateUserForm? I think that's what's intended with this library.

from reform.

apotonick avatar apotonick commented on September 28, 2024

@ivanyv That is absolutely right. However, if that makes it more convenient for people we should consider it.

from reform.

ivanyv avatar ivanyv commented on September 28, 2024

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.

fran-worley avatar fran-worley commented on September 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.