Now in my NewsStorySubmitSurface controller I have the following:
public ActionResult SubmitStory(NewsStorySubmitModel model)
{
var newsStory = Services.ContentService.CreateContent(model.Headline, GetParentId(), "newsStoryType");
// do stuff
}
What I am noticing is that my the model parameter in the code is always coming in with empty properties. However, in the Request.Form list, all the properties exist.
Obviously, I can set them by hand, but why is Umbraco not doing this automatically? If I do @Html.EditorFor(storyModel) it also appears to pass down this empty model. I guess I'll have to get the posted values manually, but it seems like I shouldn't have to.
Can you paste all of your code please. Its most likely that you have a wrong name or something invalid when passing in the model. Charlie. Are you model properties being set correctly in your form?
Thanks for the replies- what was happening was that the Model I was using to create the form was not the Model object that the page was built from- I was using StoryModel storyModel = new StoryModel() to create it, which apparently Umbraco doesn't like.
By breaking out the form functionality into a strongly typed partial, it seems to work alright- it looks as though unless the model is called "Model" it won't be passed to the SurfaceController correctly. No idea if that is an Umbraco or MVC constraint, though.
Form created with BeginUmbracoForm posts back an empty model in 6.1.6
I have a form that looks like this:
Now in my
NewsStorySubmitSurface
controller I have the following:What I am noticing is that my the
model
parameter in the code is always coming in with empty properties. However, in theRequest.Form
list, all the properties exist.Obviously, I can set them by hand, but why is Umbraco not doing this automatically? If I do
@Html.EditorFor(storyModel)
it also appears to pass down this empty model. I guess I'll have to get the posted values manually, but it seems like I shouldn't have to.Hi glanaton,
your form is in Macro Script or Partial View?
Can you paste all of your code please. Its most likely that you have a wrong name or something invalid when passing in the model. Charlie. Are you model properties being set correctly in your form?
Charlie :)
Thanks for the replies- what was happening was that the Model I was using to create the form was not the Model object that the page was built from- I was using
StoryModel storyModel = new StoryModel()
to create it, which apparently Umbraco doesn't like.By breaking out the form functionality into a strongly typed partial, it seems to work alright- it looks as though unless the model is called "Model" it won't be passed to the SurfaceController correctly. No idea if that is an Umbraco or MVC constraint, though.
is working on a reply...