Last active
December 13, 2020 01:33
-
-
Save dharmatech/9c3d30bc77d6346b2ec3a5f0f67880b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let input_helper (type_obj : System.Type) (property_name : string) (value_str : string) (name_str : string) (attrs_a : XmlAttribute list)= | |
let mutable type_value = "" | |
let mutable ls : XmlAttribute list = [] | |
let properties = type_obj.GetProperties() | |
let property_info = properties.First(fun info -> info.Name = property_name) | |
if (property_info.PropertyType.Name = "Int64") then | |
type_value <- "number" | |
else | |
type_value <- "text" | |
let attr_a = System.Attribute.GetCustomAttribute(property_info, typedefof<StringLengthAttribute>) :?> StringLengthAttribute | |
if (not (isNull attr_a)) then | |
ls <- ls @ [ attr "data-val-length-max" (string attr_a.MaximumLength) ] | |
let attrs_b = | |
[ | |
_type type_value | |
attr "data-val" "true" | |
] @ ls @ [ | |
_id name_str | |
_name name_str | |
_value value_str | |
] | |
input (attrs_a @ attrs_b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment