Giter VIP home page Giter VIP logo

Comments (9)

josevalim avatar josevalim commented on June 16, 2024

I don't follow this one.

José Valim
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

from phoenix_ecto.

sumerman avatar sumerman commented on June 16, 2024

@josevalim now if I want to show currently present items I have manually convert them to params and call cast. E.g.:

nested = build_nested_params(model.nested)
changeset = Model.changeset(changeset, %{"nested" => nested})

If I don't do this I get an empty form.

Which is quite as written in the source here and here

from phoenix_ecto.

josevalim avatar josevalim commented on June 16, 2024

Can you tell me if it would work if you build it as:

changeset = Model.changeset(changeset, :empty)

I am almost sure it is required to build a changeset. The :empty parameters does it for you.

from phoenix_ecto.

sumerman avatar sumerman commented on June 16, 2024

It does if I put a model instead of changeset as a first parameter. But in my particular case, a controller's action already have params, so it becomes Model.changeset(Model.changeset(model), params) which is not very intuitive and should be documented at least.

from phoenix_ecto.

josevalim avatar josevalim commented on June 16, 2024

@sumerman I see and I agree. I will try to find a solution.

from phoenix_ecto.

sumerman avatar sumerman commented on June 16, 2024

@josevalim thanks for this and for all your work.

from phoenix_ecto.

josevalim avatar josevalim commented on June 16, 2024

Ok, this is more complicated than expected because, for embeds, the data is always there... which means defaults would never be triggered.

When are you first generating the changeset? Are you generating it with the :empty parameter?

from phoenix_ecto.

sumerman avatar sumerman commented on June 16, 2024

First time it's generated by another controller action, then it's shown as a form to a user who modifies it then it shown as an immutable part of the form which becomes a param-only initialization of the changeset. And yes, initially it's generated with :empty parameter. Also there is a problem with Model.changeset(Model.changeset(model), params) but I will open a separate issue on elixir-lang/ecto for it.

from phoenix_ecto.

josevalim avatar josevalim commented on June 16, 2024

Fixed in master. We now always take the value in the model into account.

from phoenix_ecto.

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.