function mefibs_block_machine_name_exists in MEFIBS - More exposed forms in blocks 7
Same name and namespace in other branches
- 8 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'
- mefibs_display_extender_plugin_blocks::options_form in ./
mefibs_display_extender_plugin_blocks.inc - Provide a form to edit options for this plugin.
File
- ./
mefibs.module, line 1161 - 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;
}
// Prevent usage of "default".
if ($value == 'default') {
return TRUE;
}
if (property_exists($form_state['view'], 'form_cache')) {
$blocks = $form_state['view']->form_cache['blocks'];
foreach ($blocks as $block) {
if ($block['machine_name'] == $value) {
return TRUE;
}
}
}
return FALSE;
}