Add New Options

Hi everyone, how can I change the wording of this “add new option” when creating a new record? Thanks in advance :slight_smile:

image
image

Answered by Chris…

Add to your Javascript and inspect your form to find the correct view. I’m still at a loss to change just one instance. This will change them all on your page if you have more than one.

Best Kevin

ChrisGoode18309

Jul '19

Cara,

I was able to change the text for all options in the view to the same thing using the following:

//Change link text “add a new option”
$(document).on(‘knack-view-render.view_322’, function(event, view, data) {
$(’.kn-add-option’).text(‘Add an unlisted option’);
});

I couldn’t figure out how to do individual changes for more than one “Add a new option” but this works for me, it changes all of them to the same thing. Hope this helps.

Chris.

1 Like

This will change the “add a new option” text on the specified fields any any view where they appear:

/* Add a new option */
// Function to update the field text
function updateFieldText(selector, customText) {
var link = $(selector + ’ > div > a’);
if (link.length > 0) {
link.html(' ’ + customText);
}
}

// Array of fields and their corresponding custom text (apply globally)
var fieldMap = [
{ field: ‘#kn-input-field_31’, text: ‘Add a new XXX’ },
{ field: ‘#kn-input-field_32’, text: ‘Add a new XXX’ },
{ field: ‘#kn-input-field_428’, text: ‘Add a new XXX’ },
// Add more field/text pairs here
];

// Apply changes to any view globally
$(document).on(‘knack-view-render.any’, function(event, view, data) {
// Iterate through fieldMap and update text for any matching field
$.each(fieldMap, function(index, entry) {
updateFieldText(entry.field, entry.text);
});
});

Hi

Here’s a way we did this:

Craig