Exemplo n.º 1
0
        /// <summary>
        /// Initializes the validation on the row.
        /// </summary>
        protected virtual void InitializeValidation(HtmlGenericControl row, HtmlGenericControl labelCell, HtmlGenericControl editorCell, IFormEditorProvider editorProvider, PropertyDisplayMetadata property, DynamicDataContext dynamicDataContext)
        {
            if (dynamicDataContext.ValidationMetadataProvider.GetAttributesForProperty(property.PropertyInfo).OfType <RequiredAttribute>().Any())
            {
                labelCell.Attributes["class"] += " dynamicdata-required";
            }

            if (editorProvider.CanValidate)
            {
                row.SetValue(Validator.ValueProperty, editorProvider.GetValidationValueBinding(property, dynamicDataContext));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates the contents of the editor cell for the specified property.
 /// </summary>
 protected virtual void InitializeControlEditor(HtmlGenericControl row, HtmlGenericControl editorCell, IFormEditorProvider editorProvider, PropertyDisplayMetadata property, DynamicDataContext dynamicDataContext)
 {
     editorProvider.CreateControl(editorCell, property, dynamicDataContext);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates the contents of the label cell for the specified property.
 /// </summary>
 protected virtual void InitializeControlLabel(HtmlGenericControl row, HtmlGenericControl labelCell, IFormEditorProvider editorProvider, PropertyDisplayMetadata property, DynamicDataContext dynamicDataContext)
 {
     if (editorProvider.RenderDefaultLabel)
     {
         labelCell.Children.Add(new Literal(property.DisplayName));
     }
 }
Exemplo n.º 4
0
        protected virtual void InitializeValidation(HtmlGenericControl formGroup, HtmlGenericControl labelElement, HtmlGenericControl controlElement, IFormEditorProvider editorProvider, PropertyDisplayMetadata property, DynamicDataContext dynamicDataContext)
        {
            if (dynamicDataContext.ValidationMetadataProvider.GetAttributesForProperty(property.PropertyInfo).OfType <RequiredAttribute>().Any())
            {
                if (labelElement.Attributes.ContainsKey("class"))
                {
                    labelElement.Attributes["class"] = ControlHelpers.ConcatCssClasses(labelElement.Attributes["class"] as string, "dynamicdata-required");
                }
                else
                {
                    labelElement.Attributes["class"] = "dynamicdata-required";
                }
            }

            if (editorProvider.CanValidate)
            {
                controlElement.SetValue(DotVVM.Framework.Controls.Validator.ValueProperty, editorProvider.GetValidationValueBinding(property, dynamicDataContext));
            }
        }
Exemplo n.º 5
0
 protected virtual void InitializeControlEditor(HtmlGenericControl formGroup, HtmlGenericControl controlElement, IFormEditorProvider editorProvider, PropertyDisplayMetadata property, DynamicDataContext dynamicDataContext)
 {
     editorProvider.CreateControl(controlElement, property, dynamicDataContext);
 }
        protected virtual void InitializeControlEditor(HtmlGenericControl formGroup, HtmlGenericControl controlElement, IFormEditorProvider editorProvider, PropertyDisplayMetadata property, DynamicDataContext dynamicDataContext)
        {
            editorProvider.CreateControl(controlElement, property, dynamicDataContext);

            // set CSS classes
            foreach (var control in controlElement.GetAllDescendants())
            {
                if (control is TextBox || control is ComboBox)
                {
                    ((HtmlGenericControl)control).Attributes["class"] = "form-control";
                }
            }
        }