Code Monkey home page Code Monkey logo

Comments (8)

yousefmarey12 avatar yousefmarey12 commented on June 18, 2024 1

@thejackshelton I am done, do I PR in the reproduction repo or where exactly do I submit the PR?

from qwik.

yousefmarey12 avatar yousefmarey12 commented on June 18, 2024

@rendaoer hi, I would be willing to work on it. Can you assign me as an assignee?

from qwik.

thejackshelton avatar thejackshelton commented on June 18, 2024

@yousefmarey12 here ya go 😄

from qwik.

thejackshelton avatar thejackshelton commented on June 18, 2024

@thejackshelton I am done, do I PR in the reproduction repo or where exactly do I submit the PR?

https://github.com/QwikDev/qwik/blob/main/CONTRIBUTING.md

The contributing file here goes in-depth on how to make a PR to the Qwik repo.

Did you find the solution in the application? Or did you need to change something in the Qwik repo?

cc @yousefmarey12

from qwik.

rendaoer avatar rendaoer commented on June 18, 2024

thank you all

from qwik.

yousefmarey12 avatar yousefmarey12 commented on June 18, 2024

@thejackshelton I found the solution in the application.

from qwik.

yousefmarey12 avatar yousefmarey12 commented on June 18, 2024

@rendaoer

The Complex Forms Docs says that you get an object and not an array as a result of the form submission.

In your case, having a form name of just "worlds" would just return an object that has "worlds" as a property and ONE value since it's a key-value pair. The solution is to make the form like this

<label for="w1">A</label>
      <input id="w1" name="worlds.A" type="checkbox" value="A" />
      <label for="w2">B</label>
      <input id="w2" name="worlds.B" type="checkbox" value="B" />
      <label for="w3">C</label>
      <input id="w3" name="worlds.C" type="checkbox" value="C" />
      <button type="submit">Submit</button>

This will submit only a worlds object but its value will be the ones that you checked. The ones that you checked will of course, contain the actual value.

Now if you really want an array then you can do

export const useSubmitForm = routeAction$((data) => {
  console.log(inspect(Object.values(data.worlds), { depth: null })); // consoles the array
  zod$({ worlds: z.array(z.string()) });
});

This makes an array of the values of data.worlds and that's the array of all checked boxes for you.

Did I solve your problem?

p.s inspect is just a built-in function in node just to help me read the values.

from qwik.

rendaoer avatar rendaoer commented on June 18, 2024

@yousefmarey12
However, back-end frameworks usually provide data list acquisition or automatic type conversion. Normal form submission also has multiple checkbox data, so I think it is not intuitive.

from qwik.

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.