fix radio button state not updating in new job form
The setValueAs transformation wasn't working correctly with radio buttons in react-hook-form, causing the form value to remain a string instead of being converted to a boolean. This caused Zod validation to fail silently since the schema expects a boolean. Fixed by using controlled radio buttons with explicit onChange handlers that call setValue() with the proper boolean value. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9c9de7053c
commit
91a2894911
1 changed files with 6 additions and 4 deletions
|
|
@ -245,8 +245,9 @@ export function NewJob() {
|
|||
<label className="flex items-center">
|
||||
<input
|
||||
type="radio"
|
||||
{...register('sourceIsEnglish', { setValueAs: (v) => v === 'true' || v === true })}
|
||||
value="true"
|
||||
name="sourceIsEnglish"
|
||||
checked={sourceIsEnglish === true}
|
||||
onChange={() => setValue('sourceIsEnglish', true)}
|
||||
className="mr-2"
|
||||
/>
|
||||
<span>English</span>
|
||||
|
|
@ -254,8 +255,9 @@ export function NewJob() {
|
|||
<label className="flex items-center">
|
||||
<input
|
||||
type="radio"
|
||||
{...register('sourceIsEnglish', { setValueAs: (v) => v === 'true' || v === true })}
|
||||
value="false"
|
||||
name="sourceIsEnglish"
|
||||
checked={sourceIsEnglish === false}
|
||||
onChange={() => setValue('sourceIsEnglish', false)}
|
||||
className="mr-2"
|
||||
/>
|
||||
<span>Different language (auto-detect)</span>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue