When using the TextInput with the type=“number”, the value is set a string for the model that is bound causing an issue when attempting to save a model that expects a number is instead given a string. Is there anything extra that I need to do when using this control? I don’t want to start casting the value back to a number from a string for numerical fields.
Does AutoForm use the ServiceStack TextInput component for fields of numeric types (e.g., int , double )? If so, how does it handle marshalling the input value from a string back to a number when binding to the DTO?
The documentation that SS has for the controls mention nothing about having to do extra work to get the bindings done, and for someone using these controls for the first time it has been annoying and non productive
Yes and I wanted to know why it works. I just wanted to get going and not jump through hoops for something so trivial.
See this example below updating the Booking from the Vue spa template, I want to manually create the form, looking at the SS documentation for Vue components I assume just use the TextInput with the required type.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Nullable`1[System.Int32]. Path: $.roomNumber | LineNumber: 0 | BytePositionInLine: 24.
---> System.InvalidOperationException: Cannot get the value of a token type 'String' as a number.
I’m just giving you the perspective of someone new coming into ecosystem and running into these trivial issues where I have to now apply [SystemJson(UseSystemJson.Response)] to a model with that has number properties is frustrating as it isn’t documented anywhere you would just expect it to work. I’m using these SS and these components to save time and I’ve spent more time doing side quests as opposed to real work.
app.UseServiceStack(new AppHost(), options => {
// Use only for serializing API Responses
options.MapEndpoints(useSystemJson:UseSystemJson.Response);
});