NO BUG: form-field-ID constantly changing

Hi

I’m trying to implement the flatpickr rangePlugin on a website. For this I need the ID of the input field.

Now I have noticed that the ID of the input field is new with every page reload. Is this supposed to be the case or is it a bug?

Example:


Not a BUG.

You need to copy ID from builder not via console. In console it’s placed in name attribute.

No, I need the id attribute (e.g. #form-field-4d44f4) as a selector. But it changes all the time. Which should not be like this in my optinion, because there is not much use in a constantly changing id.
That’s why I’m asking if this is a bug or if there are legitimate reasons for this that I don’t know about.

You can use class instead of id

flatpickr( '[name="form-field-3faa4d"]' );

Edited: fixed seletor

You want to use JS or PHP to modify form? Maybe you may describe what you want to achieve more specifically…

Hi Simone,
Thanks so much for your report!

I understand it can be confusing that the “form ID” is regenerated when the page is reloaded. This is because otherwise, you could not use forms in a query loop, as IDs must be unique.

Instead of addressing the ID, you can use the name attribute as selector as suggested by Martin:
input[name="form-field-xxxxx"]

Best regards,
timmse

1 Like