I'm building a modular input that needs to keep an "API key" secret. This can be done by making the "API key" field a password field in setup.xml.
Snippet from file below
<element name="api_key" type="password" label="API key">
<view name="edit"/>
<view name="create"/>
<key name="exampleText">Private API Key</key>
</element>
However this generates a second confirmation field with the text "Confirm Password" in the form. Given my field is "API Key" can I change this second generated fields text to "Confirm API key" or some how remove the second field?
OK so I messed with this for a minute and came up with this (add it within your block statement in setup.xml)
<text>
<![CDATA[ <script type="text/javascript">
$(function() {
console.log($('label[for*="user_token_id_confirm"]'))
$('label[for*="user_token_id_confirm"]').html("Confirm User Token")
$('label[for*="data_token_id_confirm"]').html("Confirm Data Token")
});
</script> ]]>
</text>
Obviously the console.log can be removed, I used that in Chrome's Inspect so I can see I'm getting the right values
I have two input fields in my setup xml, user_token and data_token. Using the jquery selector on the confirm fields to get their labels, I then change the label text to be whatever I want.
Hope this helps.
Do you happen to have the full example to hand? I'm have trouble getting the javascript to be rendered. When I view the html source the javascript is not appearing.
<setup>
<block title="Title of page">
<text>All fields are required.</text>
</block>
<block title="Add new credentials" endpoint="storage/passwords" entity="_new">
<input field="name">
<label>Account ID</label>
<type>text</type>
</input>
<input field="password">
<label>API Key</label>
<type>password</type>
</input>
<text>
<![CDATA[ <script type="text/javascript">
$(function() {
$('label[for*="password_id_confirm"]').html("Confirm API Key")
});
</script> ]]>
</text>
</block>
</setup>
Thank you for your response I've moved on from this project and am unlikely to be testing the above solution any time soon. Hopefully, somebody else will find the solution useful and upvote it. Thanks again.