alright so im going to show my code first :
this is my server action :
const addBoard = z.object({
name : z.string().min(1),
cols : z.array(z.string().min(1))
})
export async function anotherOne(prevState : any, formData:FormData){
const rawFormData = {
name : formData.get('name'),
cols : formData.getAll('cols'),
}
const result = addBoard.safeParse(Object.fromEntries(formData.entries()))
const data = result.data
console.log(data)
return {message : "something"}
}
and this is where i call it :
const wtvr = {
message : "smtg"
}
const [error, another] = useFormState(anotherOne, wtvr)
const [fields, setFields] = useState<string[]>(["Todo", "Doing"])
return(
<form action={another} className='w-full' >
<div className='flex flex-col w-full'>
<label htmlFor="name">Board Name</label>
<input type="text" value={name} required onChange={(e)=>setName(e.target.value)} name='name' placeholder='e.g : Web Design' id='name'
className={`${fieldClassName}`}/>
<label htmlFor="columns" className='mt-3'>Board Columns</label>
{fields.map((field:string, index:number)=>(
<div className='flex flex-row items-center' key={`col_${index}`}>
<input
type="text"
id={`${index}_col`}
value={field}
className={`${fieldClassName}`}
onChange={(e)=>handleChangeField(index, e.target.value)}
required
name='cols'
/>
<div onClick={()=>handleRemoveField(index)} className='ml-1 cursor-pointer pt-1'>
<Cross/>
</div>
</div>
))}
<AddFieldButton onClick={addField}/>
<button className='text-xl text-whiteprime' type='submit'>this is a button</button>)
and i have many issues, first thing first now it doesn’t want to get me the data so when i click on submit button it just shows undefined(altho it was working two minutes ago) and the second issue is that even when it gets the data it doesn’t get all the columnst that im showing dynamically
and i don’t know exactly what i should do
ive been checking the docs but im assuming i didn’t check them properly and now im having this issue