Dynamic attributes don't work if element has no id

Hi,

Consider the following anchor link that populates the href attribute from what’s currently written inside a text input:

<a class="btn btn-primary" href="#" dmx-bind:href="bs5form.bs5input.value">

And the form:

<form>
    <input class="form-control form-control-lg" type="text" />
</form>

It’s all good if you’re using Wappler element/blocks (IDs are pre-populated), but if you paste HTML code from somewhere else you might be left wondering why dynamic attribute binding isn’t working :slight_smile:

The “bs5form.bs5input.value” was generated by Wappler (data binding picker).

Consider and Audi dealership with a used car lot. The schoolie who was hired to do odd jobs after school is told to go and wash the Audi. Off goes the schoolie to the used car section and sees to his amazement, 10 Audi’s. Without being given an ID, which Audi does he need to wash?

It is part of programming to supply ID’s where required.

Of course IDs are required for forms and inputs.
When pasting code from somewhere else, you need your code to be valid and you need some knowledge about what you are doing.

Thanks, Ben. It was an accident the ID was missing, but the bug report has another intent.

Your and Ben's point is fair, but I don't think you understood my intent with this bug report.

Wappler allowed me to data binding pick an element with no ID. In fact, your data binding picker outputted "bs5form.bs5input.value", so I assumed that would be a valid identifier within DMX's framework.

When pasting code from somewhere else, you need your code to be valid and you need some knowledge about what you are doing.

I don't like your passive-agressive tone. The copy-pasted code is HTML5 valid, there was no way I could predict Wappler would fail in this situation as your data binding picker allowed me to choose it. That's why this is a bug report, because Wappler failed to deal with an element without an ID (which is completely HTML5-compliant).

Perhaps the easiest solution here is to warn the user in case he/she attempts to pick an element without an ID in the data binding picker. Let me remind you your data binding picker outputted "bs5form.bs5input.value", which I had no reason to assume it was invalid and caused me to hang around clueless when my code was semantically correct.