First time I've tried to use Barcodes for Drupal 7 and the block didn't work. I'm surprised to find this bug, as it's pretty significant, but I guess because very few people use this module for D7, and only a fraction of those probably enable Token, chances are that maybe no one has encountered this bug before, or at least never reported it ?
Problem is that issue #2881750: Fix token module non-dependency broke the Barcode block. Specifically, that issue changed the Barcode block configuration form to look like this:
$form['settings']['value'] = [
'#type' => 'textfield',
'#title' => t('Value'),
'#description' => t('The Barcode value.'),
'#default_value' => variable_get('barcodes_value', ''),
];
if (module_exists('token')) {
$form['settings']['value'] = [
'#element_validate' => array('token_element_validate'),
'#token_types' => array(),
];
$form['settings']['token_help'] = [
'#theme' => 'token_tree_link',
'#token_types' => [],
];
}As you can see, if the token module exists, then the definition of the $form['settings']['value'] array gets OVERWRITTEN and REPLACED by the code inside the module_exists() conditional. That is most certainly NOT what we want, because when it gets overwritten then there is no textfield available to enter the 'value' for the barcode. And without a 'value', the barcode is useless.
Instead, what was intended was that the '#element_validate' and '#token_types' array elements should be ADDED TO the $form['settings']['value'] array.
Patch attached. Without the patch (and with Token enabled), there is no "Value" textfield on the block settings form at /admin/structure/block/manage/barcodes/barcode/configure. With the patch, you can go to the settings form, enter a value, and have the barcode block show a barcode for the entered value.
| Comment | File | Size | Author |
|---|---|---|---|
| block-settings-broken.patch | 482 bytes | tr |
Comments
Comment #2
tr commentedComment #3
sanduhrsAbsolutely right :)
Comment #5
sanduhrs