s-private API Documentation - v3.8.1
    Preparing search index...

    Function GenericFormWrapper

    • A generic form wrapper with server action integration.

      Type Parameters

      • T extends { message: string; success: boolean }

        Response type with message and success properties

      Parameters

      Returns Element

      A form with submit handling and loading states

      Provides a consistent form experience with:

      • Server action integration via useActionState
      • Loading state with spinner
      • Form value preservation on error
      • Context-based form state sharing
      <GenericFormWrapper
      action={createArticle}
      saveLabel="Save"
      submitLabel="Create Article"
      afterSubmit={(msg) => toast(msg)}
      >
      <FormInput label="Title" htmlFor="title" name="title" />
      <FormTextarea label="Content" htmlFor="content" name="content" />
      </GenericFormWrapper>

      useFormValues for accessing form state in child components