// Input

        public static ComponentBuilder <TConfig, Input> Input <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, string name = null, string label = null, object value = null, string valueFormat = null, FormInputType inputType = FormInputType.Text, bool addValidateMessage = false, HtmlString validateMassegeTag = null, bool isRequired = false)
            where TConfig : BootstrapConfig
            where TComponent : Component, ICanCreate <Input>
        {
            ComponentBuilder <TConfig, Input> nhelper = new ComponentBuilder <TConfig, Input>(helper.Config, new Input(helper, inputType))
                                                        .SetName(name)
                                                        .SetControlLabel(label)
                                                        .SetValue(value, valueFormat)
                                                        .SetValidateMassage(addValidateMessage, validateMassegeTag)
                                                        .SetRequired(isRequired)
                                                        .SetSize(InputSize.Sm);

            if (!string.IsNullOrEmpty(valueFormat))
            {
                Regex regex = new Regex(@"\{\d:([^)]+)\}$");
                var   match = regex.Match(valueFormat);
                if (match.Success)
                {
                    nhelper.AddAttribute("data-format", match.Groups[1].Value);
                }
            }
            if (isRequired)
            {
                nhelper.SetPlaceholder(Translation.CenterLang.Center.InputPlaceholderRequired);
            }
            return(nhelper);
        }
Exemple #2
0
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> SetConfirm <TModel, TForm>(this ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> builder, string confirmMsg)
     where TForm : Form
 {
     builder.AddAttribute("onsubmit", $"return confirm('{confirmMsg}');");
     return(builder);
 }