0

I have created a custom form in my module using Form API, the problem is it's kind of huge form (it consists lots of fields and fieldsets), I wanted to save the form as node after submission. I can create content type and map those fields, but the form is huge. I am looking for alternative way to do this and by the way I have "Taxonomy terms" in my select list in my forms, I want them to be preserved as well while saving in node.

Thank you.

  • Could you explain why you need to create a custom form which replicates the node add form? We may be able to help you a lot more than you realise. – leexonline Mar 18 '14 at 9:25
2

If you want to save the form as a node you have to add all the fields to the node type, because otherwise the database won't have tables to put all the data in.

Then, if the form you have made maps directly to the node type, then there really isn't any need for you to have a custom form, just use the normal node add page.

If you then want things to look or function a bit differently you could form alter the form to tweak things and get them the way you want them.

That is the approach I would recommend (without actually knowing what you are trying to achieve, so I am making assumptions).

The alternative is to stick with your custom form, but also make a custom database table to store all the data and enter the data into that, but then you miss out on all the modules that are already out there that provide extra functionality for nodes, you have to write your own integration with views if you want to use that, etc.

You could also do a custom entity type or use the data module, but the trouble you would go to doing this is pretty similar (or even more so) to what you would have to do if you just set it up as a node type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.