Return PHP values inside JS file Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Database credentials in PHP fileuiComponent Form. How to show data from DB tableMagento 2 form validation - accessing mage/validation/validation.js return values?Date validation on my custom form on frontend magento 2Magento 2 add custom product attribute validation from install scriptMagento 2 : How can I upload files of dynamically added file input fields in the adminMagento 2 Add new field to Magento_User admin formForm is not displayed on panel admin Magento 2Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Mysqldump return empty file .sql

Why is "Captain Marvel" translated as male in Portugal?

How can I make names more distinctive without making them longer?

How does a Death Domain cleric's Touch of Death feature work with Touch-range spells delivered by familiars?

Gastric acid as a weapon

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

Sorting numerically

How to draw this diagram using TikZ package?

Is there a service that would inform me whenever a new direct route is scheduled from a given airport?

Storing hydrofluoric acid before the invention of plastics

Center align columns in table ignoring minus signs?

Does accepting a pardon have any bearing on trying that person for the same crime in a sovereign jurisdiction?

How do I mention the quality of my school without bragging

When is phishing education going too far?

What makes black pepper strong or mild?

Why was the term "discrete" used in discrete logarithm?

Java 8 stream max() function argument type Comparator vs Comparable

Models of set theory where not every set can be linearly ordered

Should I discuss the type of campaign with my players?

What is this single-engine low-wing propeller plane?

How to find all the available tools in macOS terminal?

Is there a concise way to say "all of the X, one of each"?

What causes the vertical darker bands in my photo?

Why is "Consequences inflicted." not a sentence?

Should I call the interviewer directly, if HR aren't responding?



Return PHP values inside JS file



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Database credentials in PHP fileuiComponent Form. How to show data from DB tableMagento 2 form validation - accessing mage/validation/validation.js return values?Date validation on my custom form on frontend magento 2Magento 2 add custom product attribute validation from install scriptMagento 2 : How can I upload files of dynamically added file input fields in the adminMagento 2 Add new field to Magento_User admin formForm is not displayed on panel admin Magento 2Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Mysqldump return empty file .sql



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have an module that I need to load some informations when the user clicks at the sync button (backend). The problem is, how to retrieve the values from the js file and put them in the form.




view/adminhtml/ui_component/addfat_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">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">addfat_form.addfat_form_data_source</item>
<item name="deps" xsi:type="string">addfat_form.addfat_form_data_source</item>
</item>
<item name="label" xsi:type="string" translate="true">Nova fatura</item>
<item name="config" xsi:type="array">
<item name="dataScope" xsi:type="string">data</item>
<item name="namespace" xsi:type="string">addfat_form</item>
</item>
<item name="template" xsi:type="string">templates/form/collapsible</item>
<item name="buttons" xsi:type="array">
<item name="btn_load_client" xsi:type="string">PereiraTechFaturamentoBlockAdminhtmlButtonsEditButtonCustomButton</item>
</item>
</argument>
<dataSource name="addfat_form_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">PereiraTechFaturamentoModelDataProvider</argument>
<argument name="name" xsi:type="string">addfat_form_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">fat_id</argument>
<argument name="requestFieldName" xsi:type="string">fat_id</argument>
</argument>
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
</dataSource>
<fieldset name="title">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="collapsible" xsi:type="boolean">false</item>
<item name="label" xsi:type="string" translate="true">Nova fatura</item>
<item name="sortOrder" xsi:type="number">20</item>
</item>
</argument>
<field name="fat_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">ID da fatura</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">fat_id</item>
<item name="disabled" xsi:type="boolean">true</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
<field name="cliente_mail">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">column</item>
<item name="label" xsi:type="string" translate="true">Email do cliente</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">employee</item>
<item name="dataScope" xsi:type="string">employee_id</item>
</item>
</argument>
</field>
<field name="cliente">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Cliente</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">cliente</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
<field name="cliente_cpf_cnpj">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">CPF/CNPJ</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">cliente_cpf_cnpj</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
<field name="data_inicio">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">string</item>
<item name="label" xsi:type="string" translate="true">De</item>
<item name="formElement" xsi:type="string">date</item>
<item name="source" xsi:type="string">fatura</item>
<item name="sortOrder" xsi:type="number">20</item>
<item name="dataScope" xsi:type="string">data_inicio</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="options" xsi:type="array">
<item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
<item name="showsTime" xsi:type="boolean">false</item>
</item>
</item>
</argument>
</field>
<field name="data_fim">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">string</item>
<item name="label" xsi:type="string" translate="true">Até</item>
<item name="formElement" xsi:type="string">date</item>
<item name="source" xsi:type="string">fatura</item>
<item name="sortOrder" xsi:type="number">21</item>
<item name="dataScope" xsi:type="string">data_fim</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="options" xsi:type="array">
<item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
<item name="showsTime" xsi:type="boolean">false</item>
</item>
</item>
</argument>
</field>
<field name="vendas_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Compras</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">vendas_id</item>
</item>
<item name="options" xsi:type="object">PereiraTechFaturamentoModelDataProvider</item>
</argument>
</field>
<field name="subtotal">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">number</item>
<item name="label" xsi:type="string" translate="true">Subtotal:</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">subtotal</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
<field name="desconto">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">number</item>
<item name="label" xsi:type="string" translate="true">Desconto</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">desconto</item>
</item>
</argument>
</field>
<field name="total">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">number</item>
<item name="label" xsi:type="string" translate="true">Total</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">total</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
<field name="pago">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">boolean</item>
<item name="label" xsi:type="string" translate="true">Pago</item>
<item name="formElement" xsi:type="string">checkbox</item>
<item name="source" xsi:type="string">fatura</item>
<item name="dataScope" xsi:type="string">pago</item>
<item name="prefer" xsi:type="string">toggle</item>
<item name="valueMap" xsi:type="array">
<item name="true" xsi:type="number">1</item>
<item name="false" xsi:type="number">2</item>
</item>
<item name="default" xsi:type="number">1</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
<field name="sync" sortOrder="40" formElement="button">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="title" xsi:type="string">Sync</item>
<item name="align" xsi:type="string">center</item>
<item name="component" xsi:type="string">PereiraTech_Faturamento/js/form/element/options</item>
</item>
</argument>
</field>
</fieldset>
</form>



view/web/js/form/element/options.js




define([ 
'uiRegistry',
'Magento_Ui/js/form/components/button',
'Magento_Ui/js/modal/modal'
], function (uiRegistry, select, modal)
'use strict';

return select.extend(


action: function()
alert('ok');
return this._super();
,
);
);









share|improve this question







New contributor




Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    I have an module that I need to load some informations when the user clicks at the sync button (backend). The problem is, how to retrieve the values from the js file and put them in the form.




    view/adminhtml/ui_component/addfat_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">
    <argument name="data" xsi:type="array">
    <item name="js_config" xsi:type="array">
    <item name="provider" xsi:type="string">addfat_form.addfat_form_data_source</item>
    <item name="deps" xsi:type="string">addfat_form.addfat_form_data_source</item>
    </item>
    <item name="label" xsi:type="string" translate="true">Nova fatura</item>
    <item name="config" xsi:type="array">
    <item name="dataScope" xsi:type="string">data</item>
    <item name="namespace" xsi:type="string">addfat_form</item>
    </item>
    <item name="template" xsi:type="string">templates/form/collapsible</item>
    <item name="buttons" xsi:type="array">
    <item name="btn_load_client" xsi:type="string">PereiraTechFaturamentoBlockAdminhtmlButtonsEditButtonCustomButton</item>
    </item>
    </argument>
    <dataSource name="addfat_form_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
    <argument name="class" xsi:type="string">PereiraTechFaturamentoModelDataProvider</argument>
    <argument name="name" xsi:type="string">addfat_form_data_source</argument>
    <argument name="primaryFieldName" xsi:type="string">fat_id</argument>
    <argument name="requestFieldName" xsi:type="string">fat_id</argument>
    </argument>
    <argument name="data" xsi:type="array">
    <item name="js_config" xsi:type="array">
    <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
    </item>
    </argument>
    </dataSource>
    <fieldset name="title">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="collapsible" xsi:type="boolean">false</item>
    <item name="label" xsi:type="string" translate="true">Nova fatura</item>
    <item name="sortOrder" xsi:type="number">20</item>
    </item>
    </argument>
    <field name="fat_id">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">text</item>
    <item name="label" xsi:type="string" translate="true">ID da fatura</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">fat_id</item>
    <item name="disabled" xsi:type="boolean">true</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="cliente_mail">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">column</item>
    <item name="label" xsi:type="string" translate="true">Email do cliente</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">employee</item>
    <item name="dataScope" xsi:type="string">employee_id</item>
    </item>
    </argument>
    </field>
    <field name="cliente">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">text</item>
    <item name="label" xsi:type="string" translate="true">Cliente</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">cliente</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="cliente_cpf_cnpj">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">text</item>
    <item name="label" xsi:type="string" translate="true">CPF/CNPJ</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">cliente_cpf_cnpj</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="data_inicio">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">string</item>
    <item name="label" xsi:type="string" translate="true">De</item>
    <item name="formElement" xsi:type="string">date</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="sortOrder" xsi:type="number">20</item>
    <item name="dataScope" xsi:type="string">data_inicio</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    <item name="options" xsi:type="array">
    <item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
    <item name="showsTime" xsi:type="boolean">false</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="data_fim">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">string</item>
    <item name="label" xsi:type="string" translate="true">Até</item>
    <item name="formElement" xsi:type="string">date</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="sortOrder" xsi:type="number">21</item>
    <item name="dataScope" xsi:type="string">data_fim</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    <item name="options" xsi:type="array">
    <item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
    <item name="showsTime" xsi:type="boolean">false</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="vendas_id">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="label" xsi:type="string">Compras</item>
    <item name="dataType" xsi:type="string">text</item>
    <item name="formElement" xsi:type="string">multiselect</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">vendas_id</item>
    </item>
    <item name="options" xsi:type="object">PereiraTechFaturamentoModelDataProvider</item>
    </argument>
    </field>
    <field name="subtotal">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">number</item>
    <item name="label" xsi:type="string" translate="true">Subtotal:</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">subtotal</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="desconto">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">number</item>
    <item name="label" xsi:type="string" translate="true">Desconto</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">desconto</item>
    </item>
    </argument>
    </field>
    <field name="total">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">number</item>
    <item name="label" xsi:type="string" translate="true">Total</item>
    <item name="formElement" xsi:type="string">input</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">total</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="pago">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="dataType" xsi:type="string">boolean</item>
    <item name="label" xsi:type="string" translate="true">Pago</item>
    <item name="formElement" xsi:type="string">checkbox</item>
    <item name="source" xsi:type="string">fatura</item>
    <item name="dataScope" xsi:type="string">pago</item>
    <item name="prefer" xsi:type="string">toggle</item>
    <item name="valueMap" xsi:type="array">
    <item name="true" xsi:type="number">1</item>
    <item name="false" xsi:type="number">2</item>
    </item>
    <item name="default" xsi:type="number">1</item>
    <item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
    </item>
    </item>
    </argument>
    </field>
    <field name="sync" sortOrder="40" formElement="button">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="title" xsi:type="string">Sync</item>
    <item name="align" xsi:type="string">center</item>
    <item name="component" xsi:type="string">PereiraTech_Faturamento/js/form/element/options</item>
    </item>
    </argument>
    </field>
    </fieldset>
    </form>



    view/web/js/form/element/options.js




    define([ 
    'uiRegistry',
    'Magento_Ui/js/form/components/button',
    'Magento_Ui/js/modal/modal'
    ], function (uiRegistry, select, modal)
    'use strict';

    return select.extend(


    action: function()
    alert('ok');
    return this._super();
    ,
    );
    );









    share|improve this question







    New contributor




    Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      I have an module that I need to load some informations when the user clicks at the sync button (backend). The problem is, how to retrieve the values from the js file and put them in the form.




      view/adminhtml/ui_component/addfat_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">
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="provider" xsi:type="string">addfat_form.addfat_form_data_source</item>
      <item name="deps" xsi:type="string">addfat_form.addfat_form_data_source</item>
      </item>
      <item name="label" xsi:type="string" translate="true">Nova fatura</item>
      <item name="config" xsi:type="array">
      <item name="dataScope" xsi:type="string">data</item>
      <item name="namespace" xsi:type="string">addfat_form</item>
      </item>
      <item name="template" xsi:type="string">templates/form/collapsible</item>
      <item name="buttons" xsi:type="array">
      <item name="btn_load_client" xsi:type="string">PereiraTechFaturamentoBlockAdminhtmlButtonsEditButtonCustomButton</item>
      </item>
      </argument>
      <dataSource name="addfat_form_data_source">
      <argument name="dataProvider" xsi:type="configurableObject">
      <argument name="class" xsi:type="string">PereiraTechFaturamentoModelDataProvider</argument>
      <argument name="name" xsi:type="string">addfat_form_data_source</argument>
      <argument name="primaryFieldName" xsi:type="string">fat_id</argument>
      <argument name="requestFieldName" xsi:type="string">fat_id</argument>
      </argument>
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
      </item>
      </argument>
      </dataSource>
      <fieldset name="title">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="collapsible" xsi:type="boolean">false</item>
      <item name="label" xsi:type="string" translate="true">Nova fatura</item>
      <item name="sortOrder" xsi:type="number">20</item>
      </item>
      </argument>
      <field name="fat_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">text</item>
      <item name="label" xsi:type="string" translate="true">ID da fatura</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">fat_id</item>
      <item name="disabled" xsi:type="boolean">true</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="cliente_mail">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">column</item>
      <item name="label" xsi:type="string" translate="true">Email do cliente</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">employee</item>
      <item name="dataScope" xsi:type="string">employee_id</item>
      </item>
      </argument>
      </field>
      <field name="cliente">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">text</item>
      <item name="label" xsi:type="string" translate="true">Cliente</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">cliente</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="cliente_cpf_cnpj">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">text</item>
      <item name="label" xsi:type="string" translate="true">CPF/CNPJ</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">cliente_cpf_cnpj</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="data_inicio">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">string</item>
      <item name="label" xsi:type="string" translate="true">De</item>
      <item name="formElement" xsi:type="string">date</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="sortOrder" xsi:type="number">20</item>
      <item name="dataScope" xsi:type="string">data_inicio</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      <item name="options" xsi:type="array">
      <item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
      <item name="showsTime" xsi:type="boolean">false</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="data_fim">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">string</item>
      <item name="label" xsi:type="string" translate="true">Até</item>
      <item name="formElement" xsi:type="string">date</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="sortOrder" xsi:type="number">21</item>
      <item name="dataScope" xsi:type="string">data_fim</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      <item name="options" xsi:type="array">
      <item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
      <item name="showsTime" xsi:type="boolean">false</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="vendas_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Compras</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">multiselect</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">vendas_id</item>
      </item>
      <item name="options" xsi:type="object">PereiraTechFaturamentoModelDataProvider</item>
      </argument>
      </field>
      <field name="subtotal">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">number</item>
      <item name="label" xsi:type="string" translate="true">Subtotal:</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">subtotal</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="desconto">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">number</item>
      <item name="label" xsi:type="string" translate="true">Desconto</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">desconto</item>
      </item>
      </argument>
      </field>
      <field name="total">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">number</item>
      <item name="label" xsi:type="string" translate="true">Total</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">total</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="pago">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">boolean</item>
      <item name="label" xsi:type="string" translate="true">Pago</item>
      <item name="formElement" xsi:type="string">checkbox</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">pago</item>
      <item name="prefer" xsi:type="string">toggle</item>
      <item name="valueMap" xsi:type="array">
      <item name="true" xsi:type="number">1</item>
      <item name="false" xsi:type="number">2</item>
      </item>
      <item name="default" xsi:type="number">1</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="sync" sortOrder="40" formElement="button">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="title" xsi:type="string">Sync</item>
      <item name="align" xsi:type="string">center</item>
      <item name="component" xsi:type="string">PereiraTech_Faturamento/js/form/element/options</item>
      </item>
      </argument>
      </field>
      </fieldset>
      </form>



      view/web/js/form/element/options.js




      define([ 
      'uiRegistry',
      'Magento_Ui/js/form/components/button',
      'Magento_Ui/js/modal/modal'
      ], function (uiRegistry, select, modal)
      'use strict';

      return select.extend(


      action: function()
      alert('ok');
      return this._super();
      ,
      );
      );









      share|improve this question







      New contributor




      Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have an module that I need to load some informations when the user clicks at the sync button (backend). The problem is, how to retrieve the values from the js file and put them in the form.




      view/adminhtml/ui_component/addfat_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">
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="provider" xsi:type="string">addfat_form.addfat_form_data_source</item>
      <item name="deps" xsi:type="string">addfat_form.addfat_form_data_source</item>
      </item>
      <item name="label" xsi:type="string" translate="true">Nova fatura</item>
      <item name="config" xsi:type="array">
      <item name="dataScope" xsi:type="string">data</item>
      <item name="namespace" xsi:type="string">addfat_form</item>
      </item>
      <item name="template" xsi:type="string">templates/form/collapsible</item>
      <item name="buttons" xsi:type="array">
      <item name="btn_load_client" xsi:type="string">PereiraTechFaturamentoBlockAdminhtmlButtonsEditButtonCustomButton</item>
      </item>
      </argument>
      <dataSource name="addfat_form_data_source">
      <argument name="dataProvider" xsi:type="configurableObject">
      <argument name="class" xsi:type="string">PereiraTechFaturamentoModelDataProvider</argument>
      <argument name="name" xsi:type="string">addfat_form_data_source</argument>
      <argument name="primaryFieldName" xsi:type="string">fat_id</argument>
      <argument name="requestFieldName" xsi:type="string">fat_id</argument>
      </argument>
      <argument name="data" xsi:type="array">
      <item name="js_config" xsi:type="array">
      <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
      </item>
      </argument>
      </dataSource>
      <fieldset name="title">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="collapsible" xsi:type="boolean">false</item>
      <item name="label" xsi:type="string" translate="true">Nova fatura</item>
      <item name="sortOrder" xsi:type="number">20</item>
      </item>
      </argument>
      <field name="fat_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">text</item>
      <item name="label" xsi:type="string" translate="true">ID da fatura</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">fat_id</item>
      <item name="disabled" xsi:type="boolean">true</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="cliente_mail">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">column</item>
      <item name="label" xsi:type="string" translate="true">Email do cliente</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">employee</item>
      <item name="dataScope" xsi:type="string">employee_id</item>
      </item>
      </argument>
      </field>
      <field name="cliente">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">text</item>
      <item name="label" xsi:type="string" translate="true">Cliente</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">cliente</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="cliente_cpf_cnpj">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">text</item>
      <item name="label" xsi:type="string" translate="true">CPF/CNPJ</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">cliente_cpf_cnpj</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="data_inicio">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">string</item>
      <item name="label" xsi:type="string" translate="true">De</item>
      <item name="formElement" xsi:type="string">date</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="sortOrder" xsi:type="number">20</item>
      <item name="dataScope" xsi:type="string">data_inicio</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      <item name="options" xsi:type="array">
      <item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
      <item name="showsTime" xsi:type="boolean">false</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="data_fim">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">string</item>
      <item name="label" xsi:type="string" translate="true">Até</item>
      <item name="formElement" xsi:type="string">date</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="sortOrder" xsi:type="number">21</item>
      <item name="dataScope" xsi:type="string">data_fim</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      <item name="options" xsi:type="array">
      <item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
      <item name="showsTime" xsi:type="boolean">false</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="vendas_id">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="label" xsi:type="string">Compras</item>
      <item name="dataType" xsi:type="string">text</item>
      <item name="formElement" xsi:type="string">multiselect</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">vendas_id</item>
      </item>
      <item name="options" xsi:type="object">PereiraTechFaturamentoModelDataProvider</item>
      </argument>
      </field>
      <field name="subtotal">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">number</item>
      <item name="label" xsi:type="string" translate="true">Subtotal:</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">subtotal</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="desconto">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">number</item>
      <item name="label" xsi:type="string" translate="true">Desconto</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">desconto</item>
      </item>
      </argument>
      </field>
      <field name="total">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">number</item>
      <item name="label" xsi:type="string" translate="true">Total</item>
      <item name="formElement" xsi:type="string">input</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">total</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="pago">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="dataType" xsi:type="string">boolean</item>
      <item name="label" xsi:type="string" translate="true">Pago</item>
      <item name="formElement" xsi:type="string">checkbox</item>
      <item name="source" xsi:type="string">fatura</item>
      <item name="dataScope" xsi:type="string">pago</item>
      <item name="prefer" xsi:type="string">toggle</item>
      <item name="valueMap" xsi:type="array">
      <item name="true" xsi:type="number">1</item>
      <item name="false" xsi:type="number">2</item>
      </item>
      <item name="default" xsi:type="number">1</item>
      <item name="validation" xsi:type="array">
      <item name="required-entry" xsi:type="boolean">true</item>
      </item>
      </item>
      </argument>
      </field>
      <field name="sync" sortOrder="40" formElement="button">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="title" xsi:type="string">Sync</item>
      <item name="align" xsi:type="string">center</item>
      <item name="component" xsi:type="string">PereiraTech_Faturamento/js/form/element/options</item>
      </item>
      </argument>
      </field>
      </fieldset>
      </form>



      view/web/js/form/element/options.js




      define([ 
      'uiRegistry',
      'Magento_Ui/js/form/components/button',
      'Magento_Ui/js/modal/modal'
      ], function (uiRegistry, select, modal)
      'use strict';

      return select.extend(


      action: function()
      alert('ok');
      return this._super();
      ,
      );
      );






      magento2 database javascript adminhtml uicomponent






      share|improve this question







      New contributor




      Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Apr 11 at 21:35









      Murilo PereiraMurilo Pereira

      244




      244




      New contributor




      Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Murilo Pereira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Murilo Pereira is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269790%2freturn-php-values-inside-js-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Murilo Pereira is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Murilo Pereira is a new contributor. Be nice, and check out our Code of Conduct.












          Murilo Pereira is a new contributor. Be nice, and check out our Code of Conduct.











          Murilo Pereira is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269790%2freturn-php-values-inside-js-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Sum ergo cogito? 1 nng

          三茅街道4182Guuntc Dn precexpngmageondP