Add/Edit Custom Content Type using a Custom Form

766 views Asked by At

I have developed a module with a custom content type and with the use of a custom form, I'm grabbing the required details form the user. When the form gets submitted, I'm creating a new node of my content type programmatically.

The problem I am facing is the Edit process, how can I populate my form with the details of a specific node? what is the best approach to get this done.

Also, what is the best approach to create a form for a Custom Content Type? I have defined each and every element in my form separately and I'm wondering if there is a way to generate the form automatically with required HTML based on the node type.

1

There are 1 answers

2
MilanG On

You can use the same form (page) you are using for adding node in your content type in back-end. Just alter theme that is used for that page.

Alternately, you can create your own form programmatically and when form is submitted correct just get submitted data, create and save node in your content type and redirect to some page.

Or user webform module, create your form with it's api and hook that form submission and insert again your code that will collect the submitted data and create new node.

What's the exact problem you are facing here?