I am interested in creating barcodes from field data on-the-fly using the http://drupal.org/project/barcode module. As a rookie, could somebody explain to us how generally this is done and what is the best approach. For my working project example, I've already installed the said module and integrated a field into a Field Collection, but don't really want to spend more hours 'experimenting' to result on nothing. One idea I would like to explore is a QR barcode dynamically appearing on say a user home page (created via Views/Panels). Since my other interests are in music, a working example maybe a link to a band's website (i.e I create a 'Link' field in a Field Collection about a rock band, a visitor views the rock bands 'Homepage' on a D7 site, the link is dynamically shown as a QR code). This example is probably very common and portable across other content sites (trades, places of interest, 'Buy Now' links etc), but a decent 'how to/work through' or generalisation would be most welcome. Again, possibly it is something that can be done in Views or a case of backend PHP in a custom module (in which case I've a lot to learn). Thanks in advance.

1 Answer 1


It looks like a barcode is just a piece of encoded text from the .module file:

 * Implements hook_field_info().
function barcode_field_info() {
  return array(
    'barcode_field' => array(
      'label' => t('Barcode'),
      'description' => t('This field stores a barcode in the database.'),
      'default_widget' => 'barcode_textfield',
      'enable_tokens' => 1,
      'default_formatter' => 'barcode_default',

So what you likely want to do is creating link fields that upon form submission pass their values onto the barcode field(s) as well. Then, you will show the barcode field(s) on any pages you want and hide the raw link field from the users view (unless their editing the entry).

You could look at the Rules module to automate this for you if you don't want to write a module (for example, when a new piece of content of type Foo, if field link is blah, copy field value to field my_barcode value). Look into the Form API to hide (with #access)the field_barcode values in the edit form (as they are dynamic end-user stuff).

The only thing that the Link field gives you over putting the raw url link in the bar_code field itself is extra form validation for free (for example, check it is a valid URL).

  • Thank you, your feedback is great and very much appreciated. Thanks for the time taken.
    – Paul B
    Aug 7, 2012 at 10:51
  • 1
    I ultimately chose this module: drupal.org/project/page_url_qr_code_block does the job spot on. Thanks all.
    – Paul B
    May 8, 2016 at 14:52
  • @Paul B: Your "solution" does not address any of the needs you presented in the question. The only thing the page_url_qr_code_block module does is to provide a block that shows a QR code of the current page URL. It does not let you decide what to put in the code. Specifically, you can't display a QR code for a field value or for a link to a band's website like you asked for.
    – anonymous
    Sep 13, 2021 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.