I've added the confirmed field with a
view\adminhtml\ui_component\customer_form.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="customer">
<field name="confirmed">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">customer</item>
<item name="label" translate="true" xsi:type="string">Confirmed</item>
<item name="sortOrder" xsi:type="string">210</item>
<item name="formElement" xsi:type="string">select</item>
<item name="dataType" xsi:type="string">select</item>
</item>
</argument>
</field>
</fieldset>
</form>
The field is shown, but not with correct values, always the default one.
Now I need to change the customer retrieved data to get this field with Yes
if the customer is already confirmed and No
if not confirmed.
How can I process the data for the form?
EDIT: I have also created an observer (to set the correct value) using the
customer_load_after
inadminhtml/events.xml
<event name="customer_load_after">
<observer name="customerLoad" instance="<Vendor>\<Module>\Observer\Backend\CustomerLoadObserver" />
</event>
For testing, I tried changing the customer firstname. But it only worked for the admin page title (in the h1 class="page-title"), the customer form fields still have the values from database.