function mefibs_block_machine_name_exists in MEFIBS - More exposed forms in blocks 8
Same name and namespace in other branches
- 7 mefibs.module \mefibs_block_machine_name_exists()
Callback function for a blocks machine_name form element.
Parameters
string $value :
Return value
boolean
1 string reference to 'mefibs_block_machine_name_exists'
- MefibsDisplayExtender::buildOptionsForm in lib/
Drupal/ mefibs/ Plugin/ views/ display_extender/ MefibsDisplayExtender.php - Provide a form to edit options for this plugin.
File
- ./
mefibs.module, line 427 - Primarily Drupal hooks and global API functions to manipulate views and to provide an additional block with an exposed filter form.
Code
function mefibs_block_machine_name_exists($value, $element, $form_state) {
// Check which button has triggered the submit. We need to verify uniqueness
// of the given value only when a new block should be added.
$button = $form_state['triggering_element'];
if (!isset($button['#group'])) {
return FALSE;
}
if ($button['#group'] !== 'add') {
return FALSE;
}
if (!isset($form_state['view']->form_cache['blocks'])) {
return FALSE;
}
$blocks = $form_state['view']->form_cache['blocks'];
foreach ($blocks as $block) {
if ($block['machine_name'] == $value) {
return TRUE;
}
}
return FALSE;
}