Skip to content

Customize id prefix of root_ from rendered DOM #796

@edi9999

Description

@edi9999

Prerequisites

  • I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

The bug is that the generated DOM contains ids, which are not guaranteed to be unique, if for example I have two forms on the same page.
I think we should not use ids at all in the generated DOM, but probably if we want to identify fields, we could use data attributes such as :

<input data-rjsf={id}/>

Actual behavior

The generated DOM is full of ids.

See this example :

  <fieldset>
    <legend id="root__title">A registration form</legend>
    <p id="root__description" class="field-description">A simple
    form example.</p>
    <div class="form-group field field-string">
      <label class="control-label" for="root_firstName">First
      name*</label><input type="text" class="form-control" value=
      "Chuck" id="root_firstName" label="First name" required=""
      placeholder="">
    </div>
    <div class="form-group field field-string">
      <label class="control-label" for="root_lastName">Last
      name*</label><input type="text" class="form-control" value=
      "Norris" id="root_lastName" label="Last name" required=""
      placeholder="">
    </div>
    <div class="form-group field field-integer">
      <label class="control-label" for="root_age">Age of
      person</label>
      <p id="root_age__description" class="field-description">
      (earthian year)</p><input type="number" class="form-control"
      value="75" id="root_age" label="Age" placeholder="">
    </div>
    <div class="form-group field field-string">
      <label class="control-label" for="root_bio">Bio</label>
      <textarea id="root_bio" class="form-control" placeholder=
      "">Roundhouse kicking asses since 1940</textarea>
    </div>
    <div class="form-group field field-string">
      <label class="control-label" for=
      "root_password">Password</label><input type="password" class=
      "form-control" value="noneed" id="root_password" label=
      "Password" placeholder="">
      <p class="help-block">Hint: Make it strong!</p>
    </div>
    <div class="form-group field field-string">
      <label class="control-label" for=
      "root_telephone">Telephone</label><input type="tel" class=
      "form-control" value="" id="root_telephone" label="Telephone"
      placeholder="">
    </div>
  </fieldset>

Version

1.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions