doucuo1642 2018-08-17 15:56
浏览 176

magento2将表单保存到core_config_data

I am using magento2. I have form with few "ui_components" fields, lets say: field1, field2 ,field3 and Save button How can I save values that was enter to all fields to core_config_data?

regarding core_config_data I know that I have to use this, to save data there: use Magento\Framework\App\Config\ScopeConfigInterface;

/**
 *  @var \Magento\Framework\App\Config\Storage\WriterInterface
 */
protected $configWriter;

/**
 *
 * @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter
 */
public function __construct(
    ....
    \Magento\Framework\App\Config\Storage\WriterInterface $configWriter
    .....
)
{
    $this->configWriter = $configWriter;
}

and for calling method :

$this->configWriter->save('my/path/whatever',  $value, $scope =ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0);

I know each of the fields have its own fieldID, but how to use it to get data from it?

and how to save each of the fields values into separate core config row?

Thanks

  • 写回答

2条回答

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突