1

I have try to use register to save value and call it in some place of UiComponent such as ButtonProvider or Field OptionSource but seem it doesn't work. Is that a right way to do it or i am doing wrong
In controller i save variable to register

$this->_coreRegistry->register('someVal',data);

In another place i get data by registry

$this->_coreRegistry->registry('someVal');

1 Answer 1

2

I found solution for my question. Use Persistor instead of registry. Some case you need to pass data to Component area such as : Form. You can use Persistor to get this data instead use registry. Registry usually use in Controllers or Models

use Magento\Framework\App\Request\DataPersistorInterface;

/**
 * @var DataPersistorInterface
 */
protected $dataPersistor;

public function __construct(
    DataPersistorInterface $dataPersistor
){
    $this->dataPersistor = $dataPersistor;
}

protected function saveDataToPersistor() {
 $this->dataPersistor->set('val', $value);
}     

To get data in persistor use get method

$this->dataPersistor->get('val');
2
  • Any chance you could show how you retrieved the information in you ui-component xml ?
    – Frank
    Nov 1, 2016 at 19:06
  • Dataprovider define in xml form responsible to retrieve and populate data.
    – mrtuvn
    Nov 2, 2016 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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