コード例 #1
0
ファイル: FormField.cs プロジェクト: fizikci/Cinar
        public string GetHtml()
        {
            StringBuilder sb = new StringBuilder();

            if (String.IsNullOrEmpty(FieldName))
            {
                return(Provider.DesignMode ? Provider.GetResource("Select field name") : String.Empty);
            }

            Type                        entityType = Provider.GetEntityType(EntityName);
            Type                        fieldType  = entityType.GetProperty(FieldName).PropertyType;
            PropertyInfo                pi         = entityType.GetProperty(FieldName);
            ColumnDetailAttribute       attrField  = (ColumnDetailAttribute)CMSUtility.GetAttribute(pi, typeof(ColumnDetailAttribute));
            EditFormFieldPropsAttribute attrEdit   = (EditFormFieldPropsAttribute)CMSUtility.GetAttribute(pi, typeof(EditFormFieldPropsAttribute));
            ControlType                 ct         = attrEdit.ControlType;

            if (ct == ControlType.Undefined)
            {
                ct = Provider.GetDefaultControlType(attrField.ColumnType, pi, attrField);
            }

            string label = FieldName.HumanReadable();

            sb.AppendFormat(@"
        <div class=""form-group"">
            <label for=""{0}"" class=""col-sm-4 control-label no-padding-right""> {1} </label>
            <div class=""{3}"">
                {2}
            </div>
        </div>", FieldName, label, GetControlHtml(fieldType, attrField, attrEdit, ct), ct == ControlType.DateTimeEdit ? "col-sm-4 col-xs-6 input-group" : "col-sm-8");

            return(sb.ToString());
        }