0

I Create Dynamic Table In Admin Panel, Each Row Contain 5 Fields That Will Be Display As Carousel In Front Page.

I Manage To Create It.

when I click Add Row Its Adding The Rows To The Table But When I Try To Saved It (Save Config Button) Its Not Saving The Rows I Created.

App/code/vendor/module/etc/adminhtml/system.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
    <tab id="kravitz" translate="label" sortOrder="10">
        <label>Kravitz</label>
    </tab>
    <section id="homeiconslider" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
        <class>separator-top</class>
        <label>Icon Slider</label>
        <tab>kravitz</tab>
        <resource>Kravitz_IconSlider::config_IconSLider</resource>
        <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
            <label>General Configuration</label>
            <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Module Enable</label>
                <comment>Set To 'Yes' If You Want The Icon Slider Module To Be display At Frontend.</comment>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
            </field>
            <field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Block title</label>
                <comment>This is Optional, Leave Empty If You Dont Want Any Title To Be Display On Icon Slider block.
                if Not Empty The Title will display At Frontend.</comment>

            </field>
        </group>

        <group id="iconslidersgroup" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
            <label>Icon Sliders</label>
            <field id="slideritems" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label" type="text">
                <frontend_model>Vendor\Module\Block\Adminhtml\Config\Form\Field\Slides</frontend_model>
                <backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
            </field>
        </group>
    </section>
</system>

App/code/vendor/module/Block/Adminhtml/Config/Form/Field/Slide.php

<?php

 namespace Vendor\Module\Block\Adminhtml\Config\Form\Field;

 class Slides extends AbstractFieldArray
 {
/**
 * {@inheritdoc}
 */
protected function _construct()
{
    $this->addColumn('label', ['label' => __('Icon Name')]);
    $this->addColumn('text', ['label' => __('ALT')]);
    $this->addColumn('link', ['label' => __('Link')]);
    $this->addColumn('image_url', ['label' => __('Image (size: 640px X 333px)'), 'style' => 'file']);
    $this->addColumn('order', ['label' => __('Order')]);

    parent::_construct();
}
 }

Any Idea Why It's Not Saving The Rows ? Ty.

0

Replace this code and check :-

<?php

namespace Vendor\Module\Block\Adminhtml\Config\Form\Field;

use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;

class Slides extends AbstractFieldArray
{
    /**
     * {@inheritdoc}
     */
    protected function _construct()
    {
        $this->addColumn('label', ['label' => __('Icon Name')]);
        $this->addColumn('text', ['label' => __('ALT')]);
        $this->addColumn('link', ['label' => __('Link')]);
        $this->addColumn('image_url', ['label' => __('Image (size: 640px X 333px)'), 'style' => 'file']);
        $this->addColumn('order', ['label' => __('Order')]);

        parent::_construct();
    }
}
4
  • Still Not Working My Friend
    – Yakir56
    Jun 30 '21 at 11:10
  • follow step like s:up and s:s:d -f and check Jun 30 '21 at 11:11
  • I did And Still No Success . i am OverRide This File (AbstractFieldArray) With Custom File that Located In the Same Folder As Slide.php, cus i want to add Image Upload Field To the Table. Thats Why I dident "use" Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
    – Yakir56
    Jun 30 '21 at 11:26
  • but Even If I Change It And Did Use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray; its Still Dont Work
    – Yakir56
    Jun 30 '21 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.