Question

I want to create a dynamic menu and link it to the pages. In the tab "Create Link" I create a link for the menu, and in the "Links Grid" tab I have to assign this link to any cms page. I now need to at least appear hidden field, which will be written values checkboxes. enter image description here

I'm adding a serialization block. But it does not create a hidden field, in which the values of checkboxes should be written

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceContainer name="content">
        <block class="Namespace\Module\Block\Adminhtml\Grid\Edit" name="add_row" />
    </referenceContainer>
    <referenceContainer name="left">
        <block class="Namespace\Module\Block\Adminhtml\Grid\Edit\Tabs" name="company_module_grid_edit_tabs">
            <block class="Namespace\Module\Block\Adminhtml\Grid\Edit\Tab\Main" name="edit_tab_main"/>
            <block class="Namespace\Module\Block\Adminhtml\Grid\Edit\Tab\Conditions" name="edit_tab_conditions"/>

            <action method="addTab">
                <argument name="name" xsi:type="string">main</argument>
                <argument name="block" xsi:type="string">edit_tab_main</argument>
            </action>
            <action method="addTab">
                <argument name="name" xsi:type="string">conditions</argument>
                <argument name="block" xsi:type="string">edit_tab_conditions</argument>
            </action>
        </block>
        <block class="Magento\Backend\Block\Widget\Grid\Serializer" name="productgrid_grid_serializer">
            <arguments>
                <argument name="input_names" xsi:type="string">indexAA</argument>
                <argument name="grid_block" xsi:type="string">edit_tab_conditions</argument>
                <argument name="callback" xsi:type="string">getSelectedPages</argument>
                <argument name="input_element_name" xsi:type="string">pages</argument>
                <argument name="reload_param_name" xsi:type="string">pages_related</argument>
            </arguments>
        </block>
    </referenceContainer>

</body>

Why not create a hidden field? I looked through all the articles, but I can not find the answer ... Thanks

Was it helpful?

Solution

My problemma decided after I moved the creation of tabs from xml to the block

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceContainer name="content">
        <block class="Namespace\Module\Block\Adminhtml\Grid\Edit" name="add_row" />
    </referenceContainer>
    <referenceContainer name="left">
        <block class="Namespace\Module\Block\Adminhtml\Grid\Edit\Tabs" name="company_module_grid_edit_tabs">
            <block class="Namespace\Module\Block\Adminhtml\Grid\Edit\Tab\Main" name="edit_tab_main"/>
            <block class="Namespace\Module\Block\Adminhtml\Grid\Edit\Tab\Conditions" name="edit_tab_conditions"/>
        </block>
                <block class="Magento\Backend\Block\Widget\Grid\Serializer" name="productgrid_grid_serializer">
                    <arguments>
                        <argument name="input_names" xsi:type="string">indexAA</argument>
                        <argument name="grid_block" xsi:type="string">edit_tab_conditions</argument>
                        <argument name="callback" xsi:type="string">getSelectedPages</argument>
                        <argument name="input_element_name" xsi:type="string">pages</argument>
                        <argument name="reload_param_name" xsi:type="string">pages_related</argument>
                    </arguments>
                </block>
    </referenceContainer>
</body>

In Tabs.php

    ...
    protected function _prepareLayout()
    {
        $this->addTab(
            'edit_tab_main',
            [
                'label' => __('Main'),
                'content' => $this->getLayout()->createBlock(
                    \Web4pro\Links\Block\Adminhtml\Grid\Edit\Tab\Main::class
                )->toHtml(),
                'active' => true
            ]
        );
        $this->addTab(
            'edit_tab_conditions',
            [
                'label' => __('Conditions'),
                'content' => $this->getLayout()->createBlock(
                    \Web4pro\Links\Block\Adminhtml\Grid\Edit\Tab\Conditions::class
                )->toHtml(),
                'active' => true
            ]
        );
        return parent::_prepareLayout();

    }
...
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top