Custom form ids

Matrix Version:
5.5.3.3

Hi,

I have a custom form where I have provided the page contents bodycopy.
In the bodycopy I have content like:

< input required type=“text” autocomplete=“given-name” name=“q320266:q1” maxlength=“40” class=“js-firstName c-form__input” aria-labelledby=“q320266_q1_label” id=“q320266_q1” >

When I export the asset xml and import it into a different environment the form asset id has changed and all the ids in the body copy will be incorrect.

Is there an easy solution to this or do I need to go through the bodycopy replacing all the ids when I move the form to a different environment ?

Thanks.

I’d replace

name=“q320266:q1”

with

name=“q%globals_asset_assetid:320266%:q1”

That should cause the assetid to get rewritten by export/import. I think. Probably. :man_shrugging:

Thank you for your reply.
In the end I had some success with:

< input required type=“text” autocomplete=“given-name” name=“q%asset_assetid^add:2%:q1” maxlength=“40” class=“js-firstName c-form__input” aria-labelledby=“q%asset_assetid^add:2%_q1_label” id=“q%asset_assetid^add:2%_q1” >

as my form sections are a predicatable sequence of asset ids as far as I can tell.

This only broke down in the Thank you page:

    %begin_response_321803_q7%
        An email confirmation has been sent to %response_321803_q7%
    %end_response%

Where I couldnt see how to integrate %asset_assetid^add:2% into %begin_response_321803_q7%

I’ll give your solution a go too.

What’s the reason for hardcoding the input field like that in the first place? Why can’t you just use a keyword and add classes via keyword replacements or via the details screen of the form field?

Not sure what the specific keyword solution would be, but the reason for coding everything in a page body area was to have full control over the layout and the label elements.

So what you can do to control the attributes is to use keyword replacements like these:

%question_field_<parent_id>_<question_id>^replace:sq-form-field:my-custom-class%

For example.