I have created a custom hidden field. I want to assign a value to the hidden field
I need to assign value from the Text field.
public class HiddenField : FieldViewModel
{
public string HiddenCustomField { get; set; }
public string textField { get; set; }
protected override void InitItemProperties(Item item)
{
// on load of form
base.InitItemProperties(item);
this.HiddenCustomField = StringUtil.GetString(item.Fields["HiddenField"].Value);
textField = item?.Fields["Text"]?.Value;
}
protected override void UpdateItemFields(Item item)
{
// upon save
base.UpdateItemFields(item);
item.Fields["HiddenField"]?.SetValue(HiddenCustomField, true);
var TextField = item.Fields["Text"];
if (TextField != null)
TextField.SetValue(textField, true);
}
}
Above is my code. I tried to read the field like item.Fields["Text"]
but it didn't work.
Is this the right way of passing a value to the hidden field or can it be done in some other way?
Any help or recommendations would be appreciated
Thanks