magento / devdocs

[Deprecated] Magento Developer Documentation
Open Software License 3.0
674 stars 1.76k forks source link

Declare a custom UI component topic needs updated code sample #6735

Closed andthink closed 4 years ago

andthink commented 4 years ago

General issue

Element 'component': This element is not expected. Expected is one of ( hidden, file, input, date, boolean, checkbox, checkboxset, email, colorPicker, select ).

Description:

Seems that using the example provided conflicts with the given xsd xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd

Possible solutions:

I'd like a working example for new component declaration.

Additional information:

Magento 2.3.4

dobooth commented 4 years ago

@serhiyzhovnir, this is the area you like to work in, no?

serhiyzhovnir commented 4 years ago

@dobooth Please, assign this issue to me. I will handle it soon. Thank you!

serhiyzhovnir commented 4 years ago

Update I was able to reproduce the issue with the example from this page: https://devdocs.magento.com/guides/v2.3/ui_comp_guide/howto/new_component_declaration.html#example-creating-a-custom-secondary-not-basic-component. The code of the error:

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): The XML in file "app/code/Magento/Customer/view/base/ui_component/customer_form.xml" is invalid:
Element 'field', attribute 'formElement': 'my_select' is not a valid value of the union type 'formElementType'.
Line: 77

Element 'component': This element is not expected. Expected is one of ( hidden, file, input, date, boolean, checkbox, checkboxset, email, colorPicker, select ).
Line: 93

Verify the XML and try again.

Exception #0 (Magento\Framework\Exception\LocalizedException): The XML in file "app/code/Magento/Customer/view/base/ui_component/customer_form.xml" is invalid:
Element 'field', attribute 'formElement': 'my_select' is not a valid value of the union type 'formElementType'.
Line: 77

Element 'component': This element is not expected. Expected is one of ( hidden, file, input, date, boolean, checkbox, checkboxset, email, colorPicker, select ).
Line: 93

Verify the XML and try again.
<pre>#1 Magento\Ui\Config\Reader->read() called at [app/code/Magento/Ui/Config/Data.php:102]
#2 Magento\Ui\Config\Data->initData() called at [app/code/Magento/Ui/Config/Data.php:136]
#3 Magento\Ui\Config\Data->get('customer_form') called at [lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php:100]
#4 Magento\Framework\View\Layout\Reader\UiComponent->interpret(&Magento\Framework\View\Layout\Reader\Context#0000000042d9827d000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d98012000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d981c7000000006a38ebb3#) called at [lib/internal/Magento/Framework/View/Layout/ReaderPool.php:105]
#5 Magento\Framework\View\Layout\ReaderPool->interpret(&Magento\Framework\View\Layout\Reader\Context#0000000042d9827d000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d981c7000000006a38ebb3#) called at [lib/internal/Magento/Framework/View/Layout/Reader/Container.php:89]
#6 Magento\Framework\View\Layout\Reader\Container->interpret(&Magento\Framework\View\Layout\Reader\Context#0000000042d9827d000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d981c7000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d981f2000000006a38ebb3#) called at [lib/internal/Magento/Framework/View/Layout/ReaderPool.php:105]
#7 Magento\Framework\View\Layout\ReaderPool->interpret(&Magento\Framework\View\Layout\Reader\Context#0000000042d9827d000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d981f2000000006a38ebb3#) called at [lib/internal/Magento/Framework/View/Page/Config/Reader/Body.php:68]
#8 Magento\Framework\View\Page\Config\Reader\Body->interpret(&Magento\Framework\View\Layout\Reader\Context#0000000042d9827d000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d981f2000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d980b0000000006a38ebb3#) called at [lib/internal/Magento/Framework/View/Layout/ReaderPool.php:105]
#9 Magento\Framework\View\Layout\ReaderPool->interpret(&Magento\Framework\View\Layout\Reader\Context#0000000042d9827d000000006a38ebb3#, &Magento\Framework\View\Layout\Element#0000000042d980b0000000006a38ebb3#) called at [lib/internal/Magento/Framework/View/Layout.php:325]
#10 Magento\Framework\View\Layout->generateElements() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:89]
#11 Magento\Framework\View\Layout\Interceptor->generateElements() called at [lib/internal/Magento/Framework/View/Layout/Builder.php:129]
#12 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [lib/internal/Magento/Framework/View/Page/Builder.php:55]
#13 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [lib/internal/Magento/Framework/View/Layout/Builder.php:65]
#14 Magento\Framework\View\Layout\Builder->build() called at [lib/internal/Magento/Framework/View/Layout.php:253]
#15 Magento\Framework\View\Layout->build() called at [lib/internal/Magento/Framework/View/Layout.php:875]
#16 Magento\Framework\View\Layout->getBlock('menu') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:414]
#17 Magento\Framework\View\Layout\Interceptor->getBlock('menu') called at [app/code/Magento/Backend/Model/View/Result/Page.php:26]
#18 Magento\Backend\Model\View\Result\Page->setActiveMenu('Magento_Customer...') called at [generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php:24]
#19 Magento\Backend\Model\View\Result\Page\Interceptor->setActiveMenu('Magento_Customer...') called at [app/code/Magento/Customer/Controller/Adminhtml/Index/Edit.php:56]
#20 Magento\Customer\Controller\Adminhtml\Index\Edit->execute() called at [generated/code/Magento/Customer/Controller/Adminhtml/Index/Edit/Interceptor.php:24]
#21 Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor->execute() called at [lib/internal/Magento/Framework/App/Action/Action.php:108]
#22 Magento\Framework\App\Action\Action->dispatch(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [app/code/Magento/Backend/App/AbstractAction.php:231]
#23 Magento\Backend\App\AbstractAction->dispatch(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
#24 Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#)) called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
#25 Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [app/code/Magento/Backend/App/Action/Plugin/Authentication.php:143]
#26 Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(&Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor#0000000042d98386000000006a38ebb3#, &Closure#0000000042d99e49000000006a38ebb3#, &Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [lib/internal/Magento/Framework/Interception/Interceptor.php:135]
#27 Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
#28 Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#), NULL) called at [generated/code/Magento/Customer/Controller/Adminhtml/Index/Edit/Interceptor.php:39]
#29 Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor->dispatch(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [lib/internal/Magento/Framework/App/FrontController.php:159]
#30 Magento\Framework\App\FrontController->processRequest(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#, &Magento\Customer\Controller\Adminhtml\Index\Edit\Interceptor#0000000042d98386000000006a38ebb3#) called at [lib/internal/Magento/Framework/App/FrontController.php:99]
#31 Magento\Framework\App\FrontController->dispatch(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [lib/internal/Magento/Framework/Interception/Interceptor.php:58]
#32 Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#)) called at [lib/internal/Magento/Framework/Interception/Interceptor.php:138]
#33 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [lib/internal/Magento/Framework/Interception/Interceptor.php:153]
#34 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#), array(array('default_store_se...', 'page_cache_from_...', 'storeCookieValid...', 'install', 'configHash'))) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#35 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#0000000042d99b47000000006a38ebb3#) called at [lib/internal/Magento/Framework/App/Http.php:137]
#36 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#37 Magento\Framework\App\Http\Interceptor->launch() called at [lib/internal/Magento/Framework/App/Bootstrap.php:261]
#38 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#0000000042d99b75000000006a38ebb3#) called at [index.php:39]
</pre>

I will proceed with the investigation and I will keep you posted here.

Thank you!

shrielenee commented 4 years ago

Hey @serhiyzhovnir What is the status on this?

BarnyShergold commented 4 years ago

@shrielenee - This reads like a Magento bug issue not a docs issue - can you confirm? If it's the former it should be closed?

shrielenee commented 4 years ago

Hey @BarnyShergold I cannot confirm this is a Magento bug but will privately contact Serhiy to see if we can confirm! Thanks!

shrielenee commented 4 years ago

@BarnyShergold I talked to Sergiy. The story is that it looks more like we have described a feature in docs that never actually worked in Magento. If we desire this functionality, it should be a feature request here: https://github.com/magento/magento2.

We can't use the component as a child of the formElements node because of XML rules restrictions via the ui_configuration.xsd.

We should add a note/callout to the https://devdocs.magento.com/guides/v2.3/ui_comp_guide/howto/new_component_declaration.html#example-creating-a-custom-secondary-not-basic-component topic about the functionality not working with the applicable Magento version right now.

BarnyShergold commented 4 years ago

@shrielenee - Ah I see - well, should we not just remove the whole example? Or is it the whole "Secondary Component" feature that doesn't work? If so can we not remove everything from "Declare a custom secondary component"?

Or would that confuse? Perhaps have -

Declare a custom secondary component

The current version of Magento does not yet support secondary components.

shrielenee commented 4 years ago

@serhiyzhovnir What do you think? πŸ‘ πŸ‘Ž

shrielenee commented 4 years ago

@BarnyShergold We should probably remove or hide this information from this topic while it’s not working. It could be confusing to our audience, especially since it's a documented best practice!