Skip to content

Commit

Permalink
+ (Event) Fixed issue in the EventItemDetail block where unqualified …
Browse files Browse the repository at this point in the history
…Attributes for the Entity EventCalendarItem would cause an error if more than one calendar for them EventItem was selected.(Fixes #4878)
  • Loading branch information
ethan-sparkdevnetwork committed Mar 17, 2022
1 parent a5ca63a commit 9415bbb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Rock/Attribute/Helper.cs
Expand Up @@ -1593,7 +1593,7 @@ public static void GetEditValues( Control parentControl, Rock.Attribute.IHasAttr
{
foreach ( var attributeKeyValue in item.Attributes )
{
Control control = parentControl.FindControl( string.Format( "attribute_field_{0}", attributeKeyValue.Value.Id ) );
Control control = parentControl?.FindControl( string.Format( "attribute_field_{0}", attributeKeyValue.Value.Id ) );
if ( control != null )
{
result.AddOrIgnore( attributeKeyValue.Value, control );
Expand Down
25 changes: 17 additions & 8 deletions RockWeb/Blocks/Event/EventItemDetail.ascx.cs
Expand Up @@ -457,7 +457,8 @@ protected void btnSave_Click( object sender, EventArgs e )
foreach ( EventCalendarItem eventCalendarItem in eventItem.EventCalendarItems )
{
eventCalendarItem.LoadAttributes();
Rock.Attribute.Helper.GetEditValues( phAttributes, eventCalendarItem );
Control attributeContainer = phAttributes.FindControl( $"phAttributes_{eventCalendarItem.EventCalendarId}" );
Rock.Attribute.Helper.GetEditValues( attributeContainer, eventCalendarItem );
eventCalendarItem.SaveAttributeValues();
}
Expand Down Expand Up @@ -844,10 +845,13 @@ private void ShowReadonlyDetails( EventItem eventItem )
string value = eventCalendarItem.GetAttributeValue( attr.Key );
if ( !string.IsNullOrWhiteSpace( value ) )
{
var rl = new RockLiteral();
rl.ID = "attr_" + attr.Key;
rl.Label = attr.Value.Name;
rl.Text = attr.Value.FieldType.Field.FormatValueAsHtml( null, attr.Value.EntityTypeId, eventCalendarItem.Id, value, attr.Value.QualifierValues, false );
var rl = new RockLiteral
{
ID = $"eci{eventCalendarItem.EventCalendarId}_attr_{attr.Key}",
Label = attr.Value.Name,
Text = attr.Value.FieldType.Field.FormatValueAsHtml( null, attr.Value.EntityTypeId, eventCalendarItem.Id, value, attr.Value.QualifierValues, false )
};

phAttributesView.Controls.Add( rl );
}
}
Expand Down Expand Up @@ -925,10 +929,15 @@ private void ShowItemAttributes()

if ( eventCalendarItem.Attributes.Count > 0 )
{
var calendarAttributeHtmlGenericContainer = new HtmlGenericContainer
{
ID = $"phAttributes_{eventCalendarId}"
};

wpAttributes.Visible = true;
phAttributes.Controls.Add( new LiteralControl( string.Format( "<h3>{0}</h3>", eventCalendarService.Get( eventCalendarId ).Name ) ) );
PlaceHolder phcalAttributes = new PlaceHolder();
Rock.Attribute.Helper.AddEditControls( eventCalendarItem, phAttributes, true, BlockValidationGroup );
calendarAttributeHtmlGenericContainer.Controls.Add( new LiteralControl( string.Format( "<h3>{0}</h3>", eventCalendarService.Get( eventCalendarId ).Name ) ) );
Rock.Attribute.Helper.AddEditControls( eventCalendarItem, calendarAttributeHtmlGenericContainer, true, BlockValidationGroup );
phAttributes.Controls.Add( calendarAttributeHtmlGenericContainer );
}
}
}
Expand Down

0 comments on commit 9415bbb

Please sign in to comment.