Skip to content

Q: Form with several buttons  #442

@grimgoon

Description

@grimgoon

Hey!
I've been struggling with the following question:

const submit = ({values}) => {
  const isPublic = ?????
  await uploadBlog({ title: values.title, isPublic})
}

<Form onSubmit=(submit)>
    <TextField field="title" />
   <Button type='submit'>Save Draft</Button>
   <Button type='submit'>Create Blog</Button>
</Form>

In several cases when it comes to forms, I want to submit a form with slight alterations.
Ergo, as in the example above:

  • Saving a draft would upload a blog to the db that's not public
  • While clicking "create" would cause it to be public.

I've been racking my brain trying to figure out the cleanest way to perform this... e.g with some type of onClick event on the buttons causing a state change / some hidden input.

But, I feel like there should be a way cleaner and more straightforward way to go about this.
Does anyone have any thoughts?

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions