Can one make a input field a readonly based on a value?

I have a input field.

<input type="text" id="test" name="text" value="" required>

I want to change the “properties” of this input field bases on a value.

eg.

<dmx-value id="inputfieldcheckreadonly" dmx-bind:value="{{test.data.query1[0].test == 0 ? '' : 'readonly'}}"></dmx-value>

so if the condition is 0 then it wont make it readonly… but if it is… it sould be a readonly…

cleary what i have wont work…

<input type="text" id="test" name="text"value="" required {{inputfieldcheckreadonly.value}}>

anyone have some clever way… instead of duplicating the fields…and wrapping it in a conditional region as its quite a long form …

Have you tried the dmx-bind:readonly dynamic attribute?

1 Like

me being stupid and not looking everywhere… :slight_smile: thanks

<input type="text" id="test" name="text"value="" required dmx-bind:readonly="{{inputfieldcheckreadonly.value}}">

1 Like

you’re not the only one…
I’m looking at something and not seeing it ALL THE TIME! :rofl:

1 Like