Topic: Adding field dynamically

dagaey free asked 1 year ago


When adding fields dynamically using javascript, the border of the field is now shown. for example tried adding

<div class="form-group row" id="addcf1row">
    <div class="form-outline mb-4" id="addcf1div">
        <input type="text" class="form-control shadow-none" id="addcf1" name="addcf1" value="" maxlength="50">
        <label for="addcf1" class="form-label" id="addcf1">text</label>
    </div>
</div>

Kamila Pieńkowska staff answered 1 year ago


That's because you have to init input fields if they are not present when HTML is initially loaded.

Example in docs: https://mdbootstrap.com/docs/standard/forms/input-fields/#section-dynamic-input-initialization


dagaey free commented 1 year ago

This does not work for select/date fields. Can you provide an example of how to initialize select and datepicker fields?


Kamila Pieńkowska staff commented 1 year ago

I've prepared a code example for you: https://mdbootstrap.com/snippets/standard/kpienkowska/5196028



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 6.2.0
  • Device: desktop
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: No