Adding new custom form with coding or recipes.

Topics: Administration, Core, Customizing Orchard, General, Jobs, Localization, Writing modules, Writing themes
Oct 17, 2012 at 8:43 AM

I have a content type named MyCustomForm. It contains two fields: FirstName, LastName.
Now I'm going to add new custom form based on MyCustomForm. But I want to do that without help backend. I would like to add a new custom form with coding (in Migration.cs for example) or in Recipes. How can i do that?
Any ideas?

Coordinator
Oct 17, 2012 at 5:59 PM

It's just a content type, you can create new ones from migrations. Plenty of examples of that in existing code.

Oct 18, 2012 at 9:01 AM
bertrandleroy wrote:

It's just a content type, you can create new ones from migrations. Plenty of examples of that in existing code.

Yes I can create a new content type by code. But I need to assign created content type to Custom Form (/Admin/Orchard.CustomForms). So, my question is: can I create a Custom Form by code with using My Content Type? As I understand Orchard.CustomForm doesn't support Import/Export functionality.

Coordinator
Oct 18, 2012 at 6:00 PM

Yes, and you don't need import/export (although really, it doesn't? that would be a bug). You can create or fetch an instance of any content type from the content manager and start modifying it, usually by accessing its parts using As<ThePartType>().