Hello I have already created a custom module that add a select drop-down field to the checkout step, at this moment i have the values populated hard coded, by i need to get them from db, how can i do that? This is my checkout_index_index.xml extended xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="checkout.root"> <arguments> <argument name="jsLayout" xsi:type="array"> <item name="components" xsi:type="array"> <item name="checkout" xsi:type="array"> <item name="children" xsi:type="array"> <item name="steps" xsi:type="array"> <item name="children" xsi:type="array"> <item name="shipping-step" xsi:type="array"> <item name="children" xsi:type="array"> <item name="shippingAddress" xsi:type="array"> <item name="children" xsi:type="array"> <item name="shipping-address-fieldset" xsi:type="array"> <item name="children" xsi:type="array"> <item name="custom-checkout-form-container" xsi:type="array"> <item name="component" xsi:type="string">Bodak_CheckoutCustomForm/js/view/checkout/custom-checkout-form</item> <item name="provider" xsi:type="string">checkoutProvider</item> <item name="config" xsi:type="array"> <item name="template" xsi:type="string">Bodak_CheckoutCustomForm/checkout/custom-checkout-form</item> </item> <item name="children" xsi:type="array"> <item name="custom-checkout-form-fieldset" xsi:type="array"> <item name="component" xsi:type="string">uiComponent</item> <item name="displayArea" xsi:type="string">custom-checkout-form-fields</item> <item name="children" xsi:type="array"> <item name="checkout_buyer_email" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item> <item name="config" xsi:type="array"> <item name="customScope" xsi:type="string">customCheckoutForm</item> <item name="template" xsi:type="string">ui/form/field</item> <item name="elementTmpl" xsi:type="string">ui/form/element/input</item> </item> <item name="validation" xsi:type="array"> <item name="required-entry" xsi:type="boolean">true</item> </item> <item name="provider" xsi:type="string">checkoutProvider</item> <item name="dataScope" xsi:type="string">customCheckoutForm.checkout_buyer_email</item> <item name="label" xsi:type="string">Buyer Name</item> <item name="sortOrder" xsi:type="string">2</item> </item> <item name="checkout_buyer_name" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/form/element/select</item> <item name="config" xsi:type="array"> <item name="customScope" xsi:type="string">customCheckoutForm</item> <item name="template" xsi:type="string">ui/form/field</item> <item name="elementTmpl" xsi:type="string">ui/form/element/select</item> </item> <!-- Added for drop down values hard coded--> <item name="options" xsi:type="array"> <item name="0" xsi:type="array"> <item name="label" xsi:type="string">Please Select</item> <item name="value" xsi:type="string"></item> </item> <item name="1" xsi:type="array"> <item name="label" xsi:type="string">My Value</item> <item name="value" xsi:type="string">My Value</item> </item> <item name="2" xsi:type="array"> <item name="label" xsi:type="string">My Value</item> <item name="value" xsi:type="string">My Value</item> </item> <item name="3" xsi:type="array"> <item name="label" xsi:type="string">My Value</item> <item name="value" xsi:type="string">My Value</item> </item> </item> <!-- Added for drop down values hard coded --> <item name="validation" xsi:type="array"> <item name="required-entry" xsi:type="boolean">true</item> </item> <item name="provider" xsi:type="string">checkoutProvider</item> <item name="dataScope" xsi:type="string">customCheckoutForm.checkout_buyer_name</item> <item name="label" xsi:type="string">Please Select</item> <item name="sortOrder" xsi:type="string">1</item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </argument> </arguments> </referenceBlock> </body> </page>
Already used that one, im using layoutprocessor plugin, i just need to know how to populate the fields from db, the dropdown is already created and working but the values are not from db.