You are here

function site_banner_validate_background_color_code_form in Site Banner 7

Validate background color submissions in form content.

Parameters

array $form_state: the object containing user settings

2 calls to site_banner_validate_background_color_code_form()
SiteBannerContextReactionChangeBannerBackgroundColor::options_form_validate in ./site_banner_context_reaction_functions.inc
Validate hook for context-specific site banner background color settings.
site_banner_admin_settings_form_validate in ./site_banner.admin.inc
Implements hook_form_FORM_ID_validate() for node_type_form().

File

./site_banner.admin.inc, line 323

Code

function site_banner_validate_background_color_code_form($form_state) {
  $is_custom_background_color = $form_state['values']['site_banner_background_color_select'];
  $background_color_code_as_text = $form_state['values']['site_banner_background_custom_color_form'];

  // Test that if custom color is selected, then a valid color is entered.
  if ($is_custom_background_color) {
    if (preg_match(site_banner_get_html_color_regex_pattern(), $background_color_code_as_text) != 1) {
      form_set_error('site_banner_background_custom_color_form', t('Please enter a valid hexadecimal color code for the background color (for example #ff00ff) or select an existing color.'));
    }
  }
}