I have made a custom field type to display text in my form using the below code:
public class FreeTextFieldType : FieldType
{
[Umbraco.Forms.Core.Attributes.Setting("Content", prevalues = "", description = "Enter the text to display.", control = "Umbraco.Forms.Core.FieldSetting.TextArea")]
public string Content { get; set; }
public List<Object> _value;
public FreeTextFieldType()
{
Id = new Guid("c3d48bcc-762b-4010-8727-b92a179de7ce");
Name = "Free Text";
Description = "A field used to display blocks of text";
Icon = "textfield.png";
this.RequiresScriptManager = true;
DataType = FieldDataType.LongString;
_value = new List<object>();
}
public override string RenderPreview()
{
return string.Format("<p>{0}</p>", this.Content);
}
public override string RenderPreviewWithPrevalues(List<object> prevalues)
{
return RenderPreview();
}
}
This is working apart from the conditional logic functionality. A look into the CheckRules() Javascript method reveals that the GUID of my fieldtype is not added anywhere and as such no .show() or .hide() is being called on the field.
Can anyone tell me how I get my field type to be included in the CheckRules() Javascript?
Custom FieldType Conditional Logic Fail
Hi all.
I have made a custom field type to display text in my form using the below code:
This is working apart from the conditional logic functionality. A look into the CheckRules() Javascript method reveals that the GUID of my fieldtype is not added anywhere and as such no .show() or .hide() is being called on the field.
Can anyone tell me how I get my field type to be included in the CheckRules() Javascript?
Thanks in advance,
Lewis
Comment author was deleted
How does your View look? for the custom fieldtype
@using System.Web.Mvc
@model Umbraco.Forms.Mvc.Models.FieldViewModel
@Model.AdditionalSettings.FirstOrDefault(x => x.Key == "Content").Value
Any ideas?
Comment author was deleted
Hmm is that your entire view, seems like it's not complete, maybe put it up on gist? will take a look then https://gist.github.com/
Hey Tim
That was pretty much my view minus the markup.
I realised that the reason the conditional show/hide stuff wasn't working was because I needed to add the Model ID to the element like so:
@using System.Web.Mvc
@model Umbraco.Forms.Mvc.Models.FieldViewModel
<div class="large-12 columns">
<p id="@Model.Id">@Model.AdditionalSettings.FirstOrDefault(x => x.Key == "Content").Value</p>
</div>
<!-- /.columns -->
Thanks anyway!
Comment author was deleted
Ok yeah that's true :) glad it's sorted!
is working on a reply...