Peeyush Saini
Peeyush Saini

Reputation: 1

Sitefinity 14.4 MVC - Multiple CTA Link List Using Autogenerated Field for Designer View

When using autogenerated widget properties of type array LinkModel in a complex object property of the Controller in MVC widgets (usually the Model of the widget), the properties are always null. Other simple types like strings or integers are properly persisted. MVC Autogenerated field type 'LinkModel' user selection not saving in the backend when the property is part of the widget Model.

I am using Sitefinity 14.4 MVC. I have to use Autogenerated Field to get multiple CTA Link in the Designer View. I am using below code and I am able to achieve the CTA List in Designer View but the challenge is that I am not able to get the CTA Link List. I am getting null all the time even other fields are working like Multiple Image Selector, Heading.

I have tried following lines of code.

Below Code has been written in Controller file.

    [DisplayName("Headline")]
    public string Headline { get; set; }

    [DisplayName("Caption")]
    public string Caption { get; set; }

    [DisplayName("Select Hero Banner Images")]
    [Content(Type = KnownContentTypes.Images)]
    public MixedContentContext Images { get; set; }

    [DisplayName("CTA Link List")]
    [DataType(customDataType: "linkSelector")]
    public LinkModel[] MultipleCTALinks { get; set; }

Below Code has been written in Controller Action Method.

        model.Headline = Headline ?? string.Empty;
        model.Caption = Caption ?? string.Empty;
        if (Images != null)
        {
            model.HeroImages = GetHeroImages(Images.ItemIdsOrdered);
        }
        if(MultipleCTALinks != null)
        {
            var temp = MultipleCTALinks.ToList();
        }

When I am trying to read the MultipleCTALinks value then getting null but remaining I am able to read it.

Upvotes: 0

Views: 105

Answers (0)

Related Questions