Skip to content

Instantly share code, notes, and snippets.

@jlnarvaez
Created October 21, 2021 09:34
Show Gist options
  • Save jlnarvaez/44951dc46952599d25de514e02839466 to your computer and use it in GitHub Desktop.
Save jlnarvaez/44951dc46952599d25de514e02839466 to your computer and use it in GitHub Desktop.
[Magento 2] UI Components - uiRegistry
//Initialice uiRegistry (for Chrome debug)
var uiRegistry = require('uiRegistry');
// Get all UI Components names registered on the page
uiRegistry.get(uiItem => console.log(uiItem.name));
// Get all UI Components index registered on the page
uiRegistry.get(uiItem => console.log(uiItem.index));
// Get a specific UI Component by name
uiRegistry.get('custom_field');
// Get a specific UI Component by index (id)
uiRegistry.get('index = plan_id');
// Get a specific UI Component value by index (id)
uiRegistry.get('index = plan_id').value();
// Set value to a "select" UI Component by index (id)
uiRegistry.get('index = plan_id').setOptions([{label: 'Item 1', value: 1}, {label: 'Item 2', value: 2}]);
// Create a new property on a UI Component
uiRegistry.get('index = plan_id').set('test', 'value');
// Remove a property of a UI Component
uiRegistry.get('index = plan_id').remove('test');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment