Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic form does not work with type="button". #543

Closed
AkifumiSato opened this issue Mar 26, 2024 · 1 comment
Closed

dynamic form does not work with type="button". #543

AkifumiSato opened this issue Mar 26, 2024 · 1 comment

Comments

@AkifumiSato
Copy link

AkifumiSato commented Mar 26, 2024

Describe the bug and the expected behavior

dynamic form does not work with <button type="button">. Currently it only works with type="submit", but since it does not send to the server, type="button" seems appropriate.

Conform version

v1.0.6

Steps to Reproduce the Bug or Issue

  1. below form code
  2. Add member
  3. not working
export default function Form() {
  const [form, fields] = useForm({
    onValidate({ formData }) {
      return parseWithZod(formData, { schema: teamSchema });
    },
    shouldValidate: "onBlur",
  });
  const members = fields.members.getFieldList();

  return (
    <form {...getFormProps(form)} noValidate>
      <button
        type="button"
        {...form.insert.getButtonProps({
          name: fields.members.name,
        })}
      >
        Add member
      </button>
      {members.map((member) => {
        const memberFields = member.getFieldset();
        return (
          <label htmlFor={memberFields.name.id} key={member.key}>
            name:&nbsp;
            <input name={memberFields.name.name} />
          </label>
        );
      })}
      <button type="submit">submit</button>
    </form>
  );
}

What browsers are you seeing the problem on?

No response

Screenshots or Videos

No response

Additional context

No response

@AkifumiSato
Copy link
Author

I'm closing it because I got it necessary in terms of Progressive Enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant