1

I have a problem with the prefix field.

I have set it to be optional and I added two values in "Prefix Dropdown Options": Mr;Mrs.

Everything it's correct except from the first option of the generated select, which is empty.

Here is the code:

<div class="select select__wrapper">
  <select class="select" data-bind="
    attr: {
        name: inputName,
        id: uid,
        disabled: disabled,
        'aria-describedby': getDescriptionId(),
        'aria-required': required,
        'aria-invalid': error() ? true : 'false',
        placeholder: placeholder
    },
    hasFocus: focused,
    optgroup: options,
    value: value,
    optionsCaption: caption,
    optionsValue: 'value',
    optionsText: 'label',
    optionsAfterRender: function(option, item) {
        if (item &amp;&amp; item.disabled) {
            ko.applyBindingsToNode(option, {attr: {disabled: true}}, item);
        }
    }" name="prefix" id="SO7RWP3" aria-invalid="false">
    <option data-title="" value=" "></option>
    <option data-title="Mr" value="Mr">Mr</option>
    <option data-title="Mrs" value="Mrs">Mrs</option>
  </select>
</div>

Any ideas on how to add a translation for the first option like "Select a prefix"? Thanks

2

I am not sure that I got what You want, but it seems that its enough to change

<option data-title="" value=" "></option>

to

<option data-title="" value=" ">Select a prefix</option>

.

EDIT:
In that case look into:

src/vendor/magento/module-customer/Model/Options.php

there is function getNameSuffixOptions that calls prepareNamePrefixSuffixOptions there is :

$result = array_merge([' ' => ' '], $result);

that create empty value.
Override getNameSuffixOptions function or use di after, to change this value to Select a prefix.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.