DOT

VVM

 DOCS

Version: 1.0 | 1.1 |

FormGroup

in namespace DotVVM.Framework.Controls.Bootstrap

Represents a group in the Form control.

Properties

Name Type Description Notes Default Value
Attributes Dictionary<String,Object>
attribute
inner element
static value
bindable
default
ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
Static
DataContext Object Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value.
attribute
inner element
static value
bindable
default
FormContent List<DotvvmControl> Gets or sets the content of the form group.
attribute
inner element
static value
bindable
default
ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
LabelTemplate ITemplate Gets or sets the template of the label area. This property cannot be combined with the LabelText property.
attribute
inner element
static value
bindable
default
LabelText String Gets or sets the label text. This property cannot be combined with the LabelTemplate property.
attribute
inner element
static value
bindable
default
RenderContentContainers Boolean Gets or sets whether an additional container will be rendered around the content.
attribute
inner element
static value
bindable
default
True
Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description

Usage & Scenarios

The FormGroup is used inside the Form control and renders a form field with a label.

https://getbootstrap.com/docs/3.3/css/#forms

HTML Rendered by the Control

Sample 1: FormGroup Usage

Place any content inside the FormGroup control.

The TextBox and ComboBox controls will get the class="form-control" automatically so they'll get the default Bootstrap look.

If you use the CheckBoxes and RadioButtons, make sure you use <bs:CheckBox> and <bs:RadioButton> instead of <dot:CheckBox> and <dot:RadioButton> controls. Their IsInline property will be set automatically to true so they'll get the correct padding.

<bs:Form>
  
  <bs:FormGroup LabelText="TextBox">
    <dot:TextBox Text="{value: Text}" />
    <!-- the "form-group" CSS class is added automatically to the TextBox control -->
  </bs:FormGroup>
  
  <bs:FormGroup LabelText="TextBox">
    <dot:ComboBox DataSource="{value: Items}" SelectedValue="{value: Item}" />
    <!-- the "form-group" CSS class is added automatically to the ComboBox control -->
  </bs:FormGroup>
    
  <bs:FormGroup LabelText="CheckBox">
    <bs:CheckBox Checked="{value: IsChecked}" />
    <!-- the IsInline property is set to true automatically inside the Form -->
  </bs:FormGroup>
  
  <bs:FormGroup LabelText="CheckBox3">
    <bs:RadioButton Checked="{value: Radio}" CheckedValue="{value: true}" />
    <bs:RadioButton Checked="{value: Radio}" CheckedValue="{value: false}" />
    <!-- the IsInline property is set to true automatically inside the Form -->
  </bs:FormGroup>

</bs:Form>

Text: {{value: Text}} <br />
ComboBox: {{value: Item}} <br />
CheckBox: {{value: IsChecked}} <br />
RadioButton: {{value: Radio}} <br />
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.FormGroup.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string Text { get; set; }

        public string[] Items => new[] { "one", "two", "three" };

        public string Item { get; set; } = "one";

        public bool IsChecked { get; set; }

        public bool Radio { get; set; }
    }
}

Sample 2: FormGroup LabelTemplate

If you need custom content in the label, just use the LabelTemplate property instead of LabelText.

<bs:Form>
  <bs:FormGroup>
    <LabelTemplate>
      Your favorite colors
      <bs:Button Text="Send" Click="{command: DoSomething()}"></bs:Button>
    </LabelTemplate>
    <FormContent>
      <bs:CheckBox Text="Red" Checked="{value: Red}" IsInline="true" />
      <bs:CheckBox Text="Blue" Checked="{value: Blue}" IsInline="true" />
    </FormContent>
  </bs:FormGroup>
  <span>{{value: Text}}</span>
</bs:Form>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.FormGroup.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public bool Red { get; set; } = false;
        public bool Blue { get; set; } = true;
        public string Text { get; set; }
        public void DoSomething()
        {
            if(Red && Blue)
            {
                Text = "You select two colors";
            }
            else
            {
                Text = "You select only one color";
            }
        }
    }
}

Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message