Closed azturner closed 10 years ago
Instead of validation, @azturner says to just remove current page and all of it's children from the ParentPage page-picker.
If validation was desired, we could implement IValidatableObject on the Page model and add:
public IEnumerable<ValidationResult> Validate( ValidationContext validationContext )
{
if ( ParentPageId == Id )
{
yield return new ValidationResult
( "The page cannot be its own parent", new[] { "ParentPageId", "Id" } );
}
}
However the current PagePicker control does not give any UI when the problem (not valid) occurs.
@azturner, I talked with @mikepetersonccv about this issue tonight. We also discovered the same issue exists in the AccountPicker, GroupPicker, LocationPicker (quite possibly all ItemPickers) -- so he's going to take a stab at a pattern-solution.
Currently you can set the parent page of a page to itself (or one of it's children pages) which then makes it impossible to find the page again when administering. Need to add validation to prevent this.