Restrict to Add duplicate Items from property list Item Details Pop up

Vote:
 

Hi,

In My project I have added mutiselect country check box list using PropertyList. Code is below

[Display(Name = ........................)]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor))]
[Editable(true)]
public virtual IList VisibleFor
{
get; set;

}

public class PropertyListBase : PropertyList
{

public PropertyListBase()
{

_objectSerializer = this._objectSerializerFactory.Service.GetSerializer("application/json");
}
private Injected _objectSerializerFactory;
private IObjectSerializer _objectSerializer;
protected override T ParseItem(string value)
{
return _objectSerializer.Deserialize(value);
}
public override PropertyData ParseToObject(string value)
{
ParseToSelf(value);
return this;
}
}

public class Country
{

[CultureSpecific]
[Display(Name = "Country", GroupName = SystemTabNames.PageHeader, Order = 30)]
[SelectMany(SelectionFactoryType = typeof(CountrySelectionFactory))]

public virtual string CountryName { get; set; }


}
[PropertyDefinitionTypePlugIn]
public class ContactListProperty : PropertyListBase
{

}

But the problem is , here users are allowed to select the same country more than once, by clicking the Add button mutiple times. How to avoid the same. 

Thanks in advance.

//Tanmoy

#157741
Sep 21, 2016 13:46
Vote:
 

Hello Tonmoy

You should be able to create a IValidator to achieve this. It can validate your model.

http://www.david-tec.com/2012/06/EPiServer-7-Preview---IValidator-interface/

David

#157782
Sep 21, 2016 16:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.