[Umbraco.Forms.Core.Attributes.Setting("Text To Show", prevalues = "", description = "Enter the text to show in the label.", control = "Umbraco.Forms.Core.FieldSetting.TextArea")]
public string TextToShow { get; set; }
[Umbraco.Forms.Core.Attributes.Setting("Hide Field Caption", prevalues = "", description = "Select to hide the label and only show the text", control = "Umbraco.Forms.Core.FieldSetting.Checkbox")]
public string HideFieldCaption { get; set; }
[Umbraco.Forms.Core.Attributes.Setting("Is Heading", prevalues = "", description = "Select to display the label as a heading", control = "Umbraco.Forms.Core.FieldSetting.Checkbox")]
public string IsHeading { get; set; }
[Umbraco.Forms.Core.Attributes.Setting("Ignore Field for Email", prevalues = "", description = "Select to not send the field in emails", control = "Umbraco.Forms.Core.FieldSetting.Checkbox")]
public string IgnoreFieldForEmail { get; set; }
public Label _lblText;
public List<Object> _value;
public TextLabel()
{
Id = new Guid("57ADD3AB-C3CD-464D-BCC2-3D1C05D3BF67");
Name = "Label";
Description = "A read-only field used to display blocks of text";
Icon = "textfield.png";
DataType = FieldDataType.LongString;
_value = new List<object>();
}
public override List<object> Values
{
get
{
return _value;
}
set
{
_value = value;
}
}
public override WebControl Editor
{
get
{
_lblText = new Label();
_lblText.CssClass = "label-text";
if (IsHeading == "checked") _lblText.CssClass += " heading";
_lblText.Text = umbraco.library.ReplaceLineBreaks(TextToShow);
return _lblText;
}
set
{
base.Editor = value;
}
}
public override bool HideLabel
{
get
{
return HideFieldCaption == "checked";
}
set
{
base.HideLabel = value;
}
}
public override bool SupportsRegex
{
get { return false; }
}
public override bool SupportsPrevalues
{
get { return false; }
}
public override string RenderPreview()
{
if (IsHeading == "checked")
{
return string.Format("<h6>{0}</h6>", umbraco.library.ReplaceLineBreaks(TextToShow));
}
return string.Format("<p>{0}</p>", this.TextToShow);
}
public override string RenderPreviewWithPrevalues(List<object> prevalues)
{
return RenderPreview();
}
but when I render the form I get the following error : how can I just specify not to use a view for rendering?
the partial view '/umbraco/plugins/umbracoContour/Views/Fieldtype.label.cshtml' was not found or no view engine supports the searched locations. The following locations were searched: /umbraco/plugins/umbracoContour/Views/Fieldtype.label.cshtml
Like the error message says you'll also need a view, take a look at the existing ones in /umbraco/plugins/umbracoContour/Views/ and then add /umbraco/plugins/umbracoContour/Views/Fieldtype.label.cshtml
I know this post is a bit old, but after upgrading Contour (to 3.0.6 and using MVC) we had this exact same issue when using the Label fieldtype from Contour Contrib. In order to make the Label fieldtype work, you just need to add the code Ali has written to a new file named FieldType.Label.cshtml, as Tim wrote, and place that file in the 'umbraco/plugins/umbracoContour/Views/'-folder
That means the file will only consist of two lines:
The part about RenderPreview failed only happens when initally adding or updating the field. Values are stored correctly and shows up when you view the form in the Contour module in the backoffice (and in the frontend, of course).
Contour 3.0.9 label datatype
Hi
I am trying to add a label dataype as follow :
but when I render the form I get the following error : how can I just specify not to use a view for rendering?
the partial view '/umbraco/plugins/umbracoContour/Views/Fieldtype.label.cshtml' was not found or no view engine supports the searched locations. The following locations were searched: /umbraco/plugins/umbracoContour/Views/Fieldtype.label.cshtml
any help is much appreciated?
Comment author was deleted
Like the error message says you'll also need a view, take a look at the existing ones in /umbraco/plugins/umbracoContour/Views/ and then add /umbraco/plugins/umbracoContour/Views/Fieldtype.label.cshtml
I've added that too but how can I read the value of my label in the view? any example?
Comment author was deleted
That only renders the actual control, the label is outputted in the Form.cshtml
it only renders the caption of the field not the Text To Show ?
Comment author was deleted
Ah ok yeah you can access that in the fieldtype view, check the property additionalsettings
Thanks Tim, addistionalSetting worked perfect, so the label is rendered properly on actual form now
but I still "failed preview" error on Contour section.
here is what I've added in the view in case anyone else is using my code.
Hi, looks great but could you let me know what files were edited or inserted and where as i am a total noob to this.
cheers
neil
@neil: Did you get this to work?
I know this post is a bit old, but after upgrading Contour (to 3.0.6 and using MVC) we had this exact same issue when using the Label fieldtype from Contour Contrib. In order to make the Label fieldtype work, you just need to add the code Ali has written to a new file named
FieldType.Label.cshtml
, as Tim wrote, and place that file in the'umbraco/plugins/umbracoContour/Views/'
-folderThat means the file will only consist of two lines:
After this, you're ready to go.
The part about RenderPreview failed only happens when initally adding or updating the field. Values are stored correctly and shows up when you view the form in the Contour module in the backoffice (and in the frontend, of course).
Hope this helps!
/Michael
is working on a reply...