0

Select objects to log actions when any admin users perform in the backend how to do?

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="vendor" translate="label" class="vendor" sortOrder="800">
 <label>Vendor Extensions</label>
 </tab> 
 <section id="vendor_module" translate="label" sortOrder="500" showInDefault="1" showInWebsite="1" showInStore="1">
 <label>Admin Action Log</label>
 <tab>vendor</tab>
 <resource>Vendor_Module::config</resource>
 <group id="general" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>General Configuration</label>
 <field id="enabled" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
 <label>Enabled</label>
 <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
 </field>
 <field id="clear_action_logs_days" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>Automatically Clear Action Logs after ... Days</label>
 <validate>validate-number validate-zero-or-greater</validate>
 </field>
 <field id="enable_objects" translate="label" type="multiselect" sortOrder="110" showInDefault="1" showInWebsite="0" showInStore="0">
 <label>Enable Objects</label>
 <source_model>vendor\module\Model\Config\Source\Options</source_model>
 <!--frontend_model>vendor\module\Block\Adminhtml\System\Config\Form\Field\Checkboxes</frontend_model-->
 
 </field>
 </group>
 </section>
</system>

enter image description here

asked Jun 11, 2024 at 10:32

1 Answer 1

0

as far as I understood, you want to pass the values of the "Enable Objects" shown in the screenshot given of the backend. To do so, need to pass those options in the toOptionsArray method. Your Options.php code should be like below.

<?php
namespace Vendor\Module\Model\Config\Source;
class Options implements \Magento\Framework\Data\OptionSourceInterface
{
 public function toOptionArray()
 {
 $options = array();
 $options = [
 [
 'value' => 'catalog_products',
 'label' => 'Catalog Products'
 ],
 [
 'value' => 'catalog_categories',
 'label' => 'Catalog Categories'
 ],
 ...
 ];
 
 return $options;
 }
}
answered Jun 14, 2024 at 9:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.