You are here

function _element_width_validate in Select2 Field Widget 7.2

1 string reference to '_element_width_validate'
select2widget_entityreference_widget_settings_form in ./select2widget.entityreference.inc
Implements hook_field_widget_settings_form().

File

./select2widget.entityreference.inc, line 101

Code

function _element_width_validate($element, &$form_state) {
  $element['#value'] = trim($element['#value']);
  $input = preg_replace('/^[0-9]+\\.?([0-9]+)?(px|%)$/', '', $element['#value']);
  if (!empty($element['#value']) && !empty($input)) {
    form_error($element, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "500px" or "50%"', array(
      '!name' => t($element['#title']),
    )));
  }
}