Open AliAmiresmaeili opened 2 years ago
Hi. Please follow this sandbox:
https://codesandbox.io/s/ecstatic-scott-iuzuqr?file=/src/App.js
i used react hook form controller and i did not ued onchange to set value because of controller, this link you sent did not help me , now i dont know what to do
This method may be useful:
...
const [value, setValue] = useState<DateObject | string>("");
function handleChange(dValue: DateObject) {
// console.log(dValue?.toDate?.());
const {
year,
month: { number },
day,
} = dValue;
setValue(`${year}/${number.toString().padStart(2, "0")}/${day}`); // output for exp: `1402/07/02` instead of `۱۴۰۲/۰۷/۰۲`
}
// For special cases
<input type="hidden" name="date_en" value={value} />
<DatePicker calendar={persian} locale={persian_fa} value={value} onChange={handleChange} />
...
i am using persian calendar with locale={persian_fa} and using react-hook-form , when i get values from data object of react-hook-form , it have persian numbers for data picker , i got problems when post these data to server , i can convert this string programmatically , but is there a way to get english characters from datepicker ?