I've not sure how to exactly describe what I need, and there may be an out-of-the-way box to do this, but I am relatively new to Umbraco. I have a contact form that is used in more than one place on the website. I want to componentize this form into a partial view so that I can just include it in the pages I need it on. The contact form has some CMS-controlled content that is stored in a document type. The form also must submit the inputs to a SurfaceController. The form input fields are mapped to a view model. The problem I'm having is trying to understand how I can have a templated page that can access the document type content but also utilize a view model for the form fields. It seems like I can't have two different models for the same view. I think I can load the templated content with code in the view, but to do so, I think I need to inherit from UmbracoTemplatePage and use Model.Content.AncestorOrSelf(1) to get to the root content. However, I'm getting a compilation error because Model is actually set by the @model directive to my view model. See below
Templated Page with a View Model
I've not sure how to exactly describe what I need, and there may be an out-of-the-way box to do this, but I am relatively new to Umbraco. I have a contact form that is used in more than one place on the website. I want to componentize this form into a partial view so that I can just include it in the pages I need it on. The contact form has some CMS-controlled content that is stored in a document type. The form also must submit the inputs to a SurfaceController. The form input fields are mapped to a view model. The problem I'm having is trying to understand how I can have a templated page that can access the document type content but also utilize a view model for the form fields. It seems like I can't have two different models for the same view. I think I can load the templated content with code in the view, but to do so, I think I need to inherit from UmbracoTemplatePage and use Model.Content.AncestorOrSelf(1) to get to the root content. However, I'm getting a compilation error because Model is actually set by the @model directive to my view model. See below
I solved my problem with the help from this post.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion