Replies: 4 comments 10 replies
-
|
@Valian would love to hear from you here 🙏🏼 |
Beta Was this translation helpful? Give feedback.
-
|
Hello again, @Valian 👋🏼 I have been tinkering with forms for the past two days. The API provided by A few notes: Documentation is lacking, specially when working with Ecto and their schemas. For example, it is required that Still whilst working with Ecto I had to implement defimpl LiveVue.Encoder, for: Ecto.Schema.Metadata do
def encode(metadata, opts) do
metadata
|> Map.take([:state, :source])
|> LiveVue.Encoder.encode(opts)
end
endIt is not a big deal, as you can see from the code, but I don't know if it's me who is doing something wrong. If this is intended to be implemented, when working with Ecto forms, again, I think it should be detailed on a guide - in the limit, this Finally, I have found a simple bug, but don't know how we should approach it. Basically, defimpl LiveVue.Encoder, for: Phoenix.HTML.Form do
...
cond do
backend == nil ->
Enum.reduce(opts, msg, fn {key, value}, acc ->
- String.replace(acc, "%{#{key}}", to_string(value))
+ String.replace(acc, "%{#{key}}", format_translation_value(value))
end)
end
+
+ defp format_translation_value(value) when is_list(value) do
+ value
+ |> Enum.map(&to_string/1)
+ |> Enum.join(", ")
+ end
+
+ defp format_translation_value(value) do
+ to_string(value)
+ end
endThis fixes the error, but I don't know if you are ok with it. As such, another approach would be to simply check if Enum.reduce(opts, msg, fn {key, value}, acc ->
if String.contains?(acc, "%{#{key}}") do
String.replace(acc, "%{#{key}}", to_string(value))
else
acc
end
end)P.S: When working with a A few questions, now:
(quoted from a comment inside When working with schemas that have associations or even with embedded schemas? I can take a look into this and make it work. Tho, I haven't looked at
Could you explain what you mean by this? EDIT: Found another bug. It seems that EDIT 2: What are your thoughts on using These are the changes that I think are needed to support simple forms (
For errors encoding we can simply ignore them tho and pass an empty map (?). I'm very excited about using this project and eager to contribute more :D |
Beta Was this translation helpful? Give feedback.
-
|
@ruilopesm I've made a huge progress on that one - redesigned the API, added tons of tests, ensured it supports embeds and associations. Please try it again: #70 Example project contains a solid example of a complex form. I'm looking forward to your opinion! |
Beta Was this translation helpful? Give feedback.
-
|
@Valian some feedback regarding the current state of working with forms.
This isn't need anymore, which is great.
This error still occurs. How do you think we should approach it? I have left some suggestions above, but I might have been a bit confusing 😓 |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I'm starting to use LiveVue. Chose it because of how much I like Vue and for the possible integrations with complete component libraries (configured shadcn-vue and is working very well). As in many other applications, I want to work with forms.
Vue (and other JS frameworks) tend to make use of zod for input validation. However, that approach would imply that I need to model my entities on two sides: Ecto and Vue (specifically speaking about zod) as well as validate them on both sides (client and server). I would much prefer an approach similar to what LiveView and Ecto already do, by seamlessly integrating changesets for proper server-side input validation. I like the API presented in #5 (comment).
It seems that some effort is being made in such direction by implementing
useLiveFormon a branch. Correct me if I'm wrong anduseLiveFormwould work in a different way 😅Nonetheless, I ask what is the progress on working with forms, what needs to be done and if it would be the way I have described...
Beta Was this translation helpful? Give feedback.
All reactions