Crosslight Form Builder - Nullables

7 replies. Last post: May 10, 2016 1:41 AM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

Hello Crosslight Support,

I have a question concerning nullables and Crosslight form builder.

I have the following code in my model:

public double? Amount
{
get
{
return (double?)this.GetValue(AmountPropertyMetadata);
}
set
{
this.SetValue(AmountPropertyMetadata, value);
}
}

public static EntityProperty AmountPropertyMetadata = EntityMetadata.Register(new DataEntityProperty<MyClass, double?>("Amount", true, false, false, "", "", null, true, false, false));

And the belonging metadata property:

[Editor(EditorType.NumericTextField)]
[StringInput(Placeholder = "Amount")]
[Layout(Style = LayoutStyle.DetailOnly)]
public static double? Amount;

I want to use a nullable data type, because when I create a new entry of MyClass and enter the Amount field in the UI, I don't want to clear the "0" as default entry before I can enter the real amount. I think this is not a good user experience.

Doing this with the code above works partly. When creating a new entry the form pops up and the Amount field is empty, showing only the placeholder text. Then I enter an amount, I leave the field, I get back to the amount field and clear the amount.

The result is an exception (see screenshot) while debugging and the value entered before remains in the amount field. But I want the have a clean amount field with the placeholder text.

Do you have any advice or fix?

Thanks,
Thomas

1 attachment
All times are GMT -5. The time now is 10:47 PM.
Previous Next