Contact form 7 adding custom attribute to input text

I needed to add datalist-support on contact form 7 (version 3.8) text-field.
See: http://www.w3schools.com/tags/tag_datalist.asp


After searching the web without according results I extended the preset pattern for the get_option-function in
/plugins/contact-form-7/includes/shortcodes.php
with the list-pattern (line 249). Last line of the following code:

Read More
$preset_patterns = array(
  'date' => '([0-9]{4}-[0-9]{2}-[0-9]{2}|today(.*))',
  'int' => '[0-9]+',
  'signed_int' => '-?[0-9]+',
  'class' => '[-0-9a-zA-Z_]+',
  'id' => '[-0-9a-zA-Z_]+',
  'list' => '[-0-9a-zA-Z_]+' );

and added the list-attribute (line 49) in the text-module
/plugins/contact-form-7/modules/text.php

$atts['list'] = $tag->get_option( 'list', 'list', true );

That solution is actually working. But only until the next update is applied.

Is there a better solution to this problem? (Prior to that change I used an input-text together with a select-box.)

Any hint, help or comment appreciated.

Related posts

Leave a Reply