Php Magento 2-在管理表单中添加多选状态

Php Magento 2-在管理表单中添加多选状态,php,magento,module,magento2,Php,Magento,Module,Magento2,我正在Magento 2中开发一个自定义模块。我想在编辑表单中添加一个multiselect,允许用户选择订单的状态。在Magento 1.9中,它是通过以下方式完成的: Mage::getModel('sales/order_status')->getResourceCollection()->getData(); 如何在Magento 2中实现这一点?您可以在{Vendor}/{Module}/etc/adminhtml/system.xml上添加此代码

我正在Magento 2中开发一个自定义模块。我想在编辑表单中添加一个multiselect,允许用户选择订单的状态。在Magento 1.9中,它是通过以下方式完成的:

Mage::getModel('sales/order_status')->getResourceCollection()->getData();

如何在Magento 2中实现这一点?

您可以在{Vendor}/{Module}/etc/adminhtml/system.xml上添加此代码

           <field id="order_status" translate="label" type="multiselect" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Order status</label>
                <source_model>Magento\Sales\Model\Config\Source\Order\Status</source_model>
                <comment>Select the status for the orders to be exported</comment>
            </field>

订单状态
Magento\Sales\Model\Config\Source\Order\Status
选择要导出的订单的状态

您想要订单状态选项吗?是的,我想要列出所有订单状态选项。