Return PHP values inside JS file The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)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
Can a 1st-level character have an ability score above 18?
Am I ethically obligated to go into work on an off day if the reason is sudden?
Create an outline of font
How to delete random line from file using Unix command?
Is there a writing software that you can sort scenes like slides in PowerPoint?
How did passengers keep warm on sail ships?
Segmentation fault output is suppressed when piping stdin into a function. Why?
Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?
Can the DM override racial traits?
Road tyres vs "Street" tyres for charity ride on MTB Tandem
What do you call a plan that's an alternative plan in case your initial plan fails?
How do I add random spotting to the same face in cycles?
Are spiders unable to hurt humans, especially very small spiders?
What's the point in a preamp?
How can I define good in a religion that claims no moral authority?
How does ice melt when immersed in water
Change bounding box of math glyphs in LuaTeX
Did God make two great lights or did He make the great light two?
Semisimplicity of the category of coherent sheaves?
Sort a list of pairs representing an acyclic, partial automorphism
Does Parliament need to approve the new Brexit delay to 31 October 2019?
Typeface like Times New Roman but with "tied" percent sign
Can a novice safely splice in wire to lengthen 5V charging cable?
Do warforged have souls?
Return PHP values inside JS file
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)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;
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
magento2 database javascript adminhtml uicomponent
New contributor
New contributor
New contributor
asked 2 days ago
Murilo PereiraMurilo Pereira
143
143
New contributor
New contributor
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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