Skip to content

Question about the ViewComponent part of this package #156

@DynamicDave

Description

@DynamicDave

Feature summary

Dear James,

I was trying out your package and I have a question about the ViewComponent part of this package.

I have this simple class:

public class SavedForm {
    public string? Subject { get; set; }
    public string? ContentBody { get; set; }
}

And I have a simple dashboard:
public class SavedFormsDashboard : SimpleDashboard { }

And I have a ViewComponent that returns a list of (random) SavedForm objects to a view:

public class SavedFormsDashboardViewComponent : DashboardViewComponent {
    public override IViewComponentResult Invoke(DashboardViewModel model) {
        var viewModel = SavedFormGenerator.GenerateRandomForms();
        return View("~/Views/Dashboards/SavedForms.cshtml", viewModel);
    }
}

The view is:

@inherits Umbraco.Community.SimpleDashboards.Web.DashboardViewPage
@*model List<SavedForm>*@
<uui-box headline="Hello Umbraco">
    My Dashboard is: @Model.Dashboard.Alias
</uui-box>

How do I get this to work? How do access the list of SavedForm objects in the view?
I want to show a list of the 'SavedForm' objects with this component.

Kind regards,
Dave

Additional details

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions