Search code examples
javascriptreactjsreact-bootstrap

what is a controlId in react-bootstrap


I was just going through the React-bootstrap form what is the use of controlId is it similar to name we use in legacy form?

<form>
    <FormGroup
      controlId="formBasicText" ---------------------->> what is the use?
      validationState={this.getValidationState()}
    >
      <ControlLabel>Working example with validation</ControlLabel>
      <FormControl
        type="text"
        value={this.state.value}
        placeholder="Enter text"
        onChange={this.handleChange}
      />
      <FormControl.Feedback />
      <HelpBlock>Validation is based on string length.</HelpBlock>
    </FormGroup>
  </form>

Solution

  • You can find it here in the v3 docs:

    Sets id on <FormControl> and htmlFor on <FormGroup.Label>.

    Basically it's the input's id and the label's for attribute.

    enter image description here