question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: custom input registration

See original GitHub issue

I think we could improve the DX a bit just by exporting the registered input already as a prop.

Currently if we want to make a custom input we need to do this:

<Field name="email">
  {({ Label, Errors }) => (
    <>
      <Label />
      <input
        type="email"
        {...register('email')}
        className="border-2 border-dashed rounded-md"
      />
      <Errors />
    </>
  )}
</Field>

Since the Field has the name it would make sense to just do this

<Field name="email">
  {({ Label, Errors, props }) => (
    <>
      <Label />
      <input type="email"  {...props}  className="border-2 border-dashed rounded-md" />
      <Errors />
    </>
  )}
</Field>

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
samjohndukecommented, Aug 11, 2022

Note - For those who see the above and a wondering whats going on. When using Controller, if the render of the controller doesn’t put a hidden or otherwise input into the dom, this won’t work. So its a matter of adding

<Controller
  name="dateStart"
  control={control}
  render={({ field }) => (
    <>
     <input name={field.name} value={field.value} type="hidden" />
      <Calendar
        id={field.name}
        value={field.value}
         onChange={(e) => field.onChange(e.value)}
       />
    <>
  )}
/>

Hope this helps

2reactions
danielweinmanncommented, Jun 20, 2022

Yup, the register approach is for uncontrolled components only. If you’d like to make it work with controlled components, you’ll need to use Controller or implement value and onChange by hand, using setValue to set the value.

But I think the API you suggested is good for uncontrolled custom inputs. I’ll leave the issue open until we implement it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Add Custom WooCommerce Registration Form Fields
Here are the quick and easy steps to enable WooCommerce registration form fields, and to add additional custom fields to the WooCommerce ...
Read more >
How to Create a Custom User Registration Form in WordPress
First, you need to enter a name for your form at the top and then hover over the User Registration Form template. After...
Read more >
Creating Custom Registration Fields - iThemes Help Center
This tutorial will walk you through how to add custom fields to these pages: Membership registration form [register_form]; Front-facing profile editor ...
Read more >
How to add custom fields to the WordPress registration form
In this tutorial we'll learn how to programmatically add a custom field to the default WordPress registration form.
Read more >
How to Add Extra Fields to Registration Form - Misha Rudrastyh
In this tutorial I will show how to add a phone number field into WooCommerce registration form with input mask and custom validation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found