Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GetLabelHtml returns not empty string if Display Attribute present
  • Loading branch information
zabulus committed May 5, 2015
1 parent 20329d1 commit 18915bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions ChameleonForms.Tests/FieldGenerator/DefaultFieldGeneratorTests.cs
Expand Up @@ -217,5 +217,16 @@ public void Set_field_configuration_if_readonly_attribute_applied()

Assert.That(configuration.HtmlAttributes["readonly"], Is.EqualTo("readonly"));
}

[Test]
public void GetLabelHtml_should_not_return_any_string_if_WithoutLabel_used_and_DisplayAttribute_present()
{
var generator = Arrange(x => x.StringWithDisplayAttribute);
var fieldConfig = new FieldConfiguration();
fieldConfig.WithoutLabel();
var config = generator.PrepareFieldConfiguration(fieldConfig, FieldParent.Section);
var actual = generator.GetLabelHtml(config).ToString();
Assert.That(actual, Is.Empty);
}
}
}
4 changes: 2 additions & 2 deletions ChameleonForms/FieldGenerators/DefaultFieldGenerator.cs
Expand Up @@ -60,7 +60,7 @@ public IHtmlString GetLabelHtml(IReadonlyFieldConfiguration fieldConfiguration)
?? GetFieldDisplayName().ToHtml();

if (!fieldConfiguration.HasLabel)
return labelText;
return new HtmlString(string.Empty);

var labelAttrs = new HtmlAttributes();
if (!string.IsNullOrEmpty(fieldConfiguration.LabelClasses))
Expand Down Expand Up @@ -149,4 +149,4 @@ public TModel GetModel()
return (TModel) HtmlHelper.ViewData.ModelMetadata.Model;
}
}
}
}

0 comments on commit 18915bb

Please sign in to comment.