function lightning_media_inject_entity_browser_count in Lightning Media 8.3
Same name and namespace in other branches
- 8.4 lightning_media.module \lightning_media_inject_entity_browser_count()
- 8 lightning_media.module \lightning_media_inject_entity_browser_count()
- 8.2 lightning_media.module \lightning_media_inject_entity_browser_count()
Post-build callback for entity browser elements.
This function injects the number of default values the entity browser has into its JavaScript settings so that several instances of an entity browser on a particular field can respect the field's cardinality. This is used by our special-sauce JavaScript in browser.js to ensure that you cannot select more entities than the cardinality will allow.
Parameters
array $element: The fully built element.
Return value
array The processed element.
1 string reference to 'lightning_media_inject_entity_browser_count'
- lightning_media_element_info_alter in ./
lightning_media.module - Implements hook_element_info_alter().
File
- ./
lightning_media.module, line 293 - Core media asset support for Lightning.
Code
function lightning_media_inject_entity_browser_count(array $element) {
$settings =& $element['#attached']['drupalSettings']['entity_browser'];
$uuid = key($settings);
$settings[$uuid]['count'] = count($element['#default_value']);
return $element;
}