Clone form is blank

Hi, I'm trying to create a clone form but I'm getting a blank form each time. I created my resource action and route as shown clone: "/rent_payments/clone/:id", <Route path="clone/:id" element={<RentPaymentCreate />} /> But when I navigate to /rent_payments/clone/54 I get a blank form
K
kapa.ai301d ago
Hi @ahnaf1022. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- It seems like you might not be using the useForm hook with the action: "clone" property in your RentPaymentCreate component. To create a clone form, you need to use the useForm hook with the action: "clone" property. Here's an example of how to use useForm with action: "clone":
import React from "react";
import { Create, useForm } from "@refinedev/antd";
import { Form, Input } from "antd";

interface IRentPayment {
id: number;
// Add other properties of your RentPayment model
}

const RentPaymentCreate: React.FC = () => {
const { formProps, saveButtonProps } = useForm<IRentPayment>({ action: "clone" });

return (
<Create saveButtonProps={saveButtonProps}>
<Form {...formProps} layout="vertical">
{/* Add your form items here */}
<Form.Item
label="Example Field"
name="exampleField"
rules={[
{
required: true,
},
]}
>
<Input />
</Form.Item>
</Form>
</Create>
);
};
import React from "react";
import { Create, useForm } from "@refinedev/antd";
import { Form, Input } from "antd";

interface IRentPayment {
id: number;
// Add other properties of your RentPayment model
}

const RentPaymentCreate: React.FC = () => {
const { formProps, saveButtonProps } = useForm<IRentPayment>({ action: "clone" });

return (
<Create saveButtonProps={saveButtonProps}>
<Form {...formProps} layout="vertical">
{/* Add your form items here */}
<Form.Item
label="Example Field"
name="exampleField"
rules={[
{
required: true,
},
]}
>
<Input />
</Form.Item>
</Form>
</Create>
);
};
Make sure to replace the IRentPayment interface and form items with your actual model properties. For more information, refer to the refine documentation on useForm with action: "clone" (https://refine.dev/docs/api-reference/core/hooks/useForm#action-clone). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
K
kapa.ai301d ago
<@543682490951532554> kapa.ai is still learning and improving, please let us how it did by reacting below
R
rival-black301d ago
this is not enough information to debug 😦 do you have an error on network ? is your show page works ? if you provide reproducible example, i'm happy to debug
F
fascinating-indigo301d ago
Okay I will try to create a code sandbox @alicanerdurmaz I figured out the problem. Turns out it was because I included initialValues in the Form <Form {...formProps} layout="vertical" initialValues={{ ... }}> After removing initialValues it works fine
More Posts
"extends": "../../tsconfig.build.json",file tsconfig.build.json not found.. how to fix it? I installed refine with NextJsIs it possible to avoid generating the filter query string when there are filters for tables/lists?Hello! I'm trying to create a filter component for my tables and list but I would like to avoid alsoIs it possible to develop micro-frontends using Refine?Is it possible to create a Refine view that can be embedded within another website, similar to an iFhow can retrieve the avatar attribute in the strapi api user and show it in refineStrapiNextjs installationThere are lots of issues I am facing while installing refine with nextjs package, if anyone have creI am having issues using access control using cerbosI have imported the example implementation of access controll using cerbos and it has code as folloUnhandled Error in logout: refine always expects a resolved promise.```logout: async ({ email, password }) => { localStorage.removeItem("auth"); return ConfigProvider ant designI am still struggeling to customize the ant design button on the login page by adding a provider conLog Out User If JWT has expired.@kapa.ai , Lets say i am logged in as a user in my refine app and my jwt token has expired, then wheAm I stupid or whatAm I stupid or what? `const { data, error } = useList<ApiData, HttpError>({...})` - type of `error`So I installed Refine with all theSo, I installed Refine with all the necessary dependencies. However I'm trying to edit(Sider) of thefiltersHow to filter the created at field with between operatorHi everyone I m new to refine and IHi everyone, I'm new to refine and I couldn't find anywhere a nice way to make a useSelect depend onDependency between two useSelectIs there any way to acheive a Select form item depending on another one. Suppose we have tow Select Frontend in React to refine.devHi , i'm a new bie , can someone give me an hint in how to connect a Frontend in React to refine.devRequest for Assistance with useDataGridHello, I hope this message finds you well. I am reaching out because I am currently facing an issue