/** * Theme override function to output bootstrap-style textfield. * This is a workaround for the issue that bootstrap_element_info_alter * can be skipped due to theme not yet being initialized when drupal_alter * call made. * * @ingroup themeable * @see theme_textfield */ function cignaglobal_textfield($vars) { $element = $vars['element']; $element['#attributes']['type'] = 'text'; element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength')); // Add form-control class if it does not exist. $classes = array('form-text'); if (!isset($element['#attributes']['class']) || !in_array('form-control', $element['#attributes']['class'])) { $classes[] = 'form-control'; } _form_set_class($element, $classes); $extra = ''; if ($element['#autocomplete_path'] && !empty($element['#autocomplete_input'])) { drupal_add_library('system', 'drupal.autocomplete'); $element['#attributes']['class'][] = 'form-autocomplete'; $attributes = array(); $attributes['type'] = 'hidden'; $attributes['id'] = $element['#autocomplete_input']['#id']; $attributes['value'] = $element['#autocomplete_input']['#url_value']; $attributes['disabled'] = 'disabled'; $attributes['class'][] = 'autocomplete'; $extra = '<input' . drupal_attributes($attributes) . ' />'; } $output = '<input' . drupal_attributes($element['#attributes']) . ' />'; return $output . $extra; }
/** * Overrides theme_textfield(). */ function bootstrap_sst_textfield($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'text'; element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength')); _form_set_class($element, array('form-text')); $output = '<input' . drupal_attributes($element['#attributes']) . ' />'; $extra = ''; if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) { drupal_add_library('system', 'drupal.autocomplete'); $element['#attributes']['class'][] = 'form-autocomplete'; $attributes = array(); $attributes['type'] = 'hidden'; $attributes['id'] = $element['#attributes']['id'] . '-autocomplete'; $attributes['value'] = url($element['#autocomplete_path'], array('absolute' => TRUE)); $attributes['disabled'] = 'disabled'; $attributes['class'][] = 'autocomplete'; // Uses icon for autocomplete "throbber". if ($icon = _bootstrap_icon('refresh')) { $output = '<div class="input-group">' . $output . '<span class="input-group-addon">' . $icon . '</span></div>'; } else { $output = '<div class="input-group">' . $output . '<span class="input-group-addon">'; // The throbber's background image must be set here because sites may not // be at the root of the domain (ie: /) and this value cannot be set via // CSS. $output .= '<span class="autocomplete-throbber" style="background-image:url(' . url('misc/throbber.gif') . ')"></span>'; $output .= '</span></div>'; } $extra = '<input' . drupal_attributes($attributes) . ' />'; } return $output . $extra; }
/** * Pre-processes variables for the "bootstrap_panel" theme hook. * * See template for list of available variables. * * @see bootstrap-panel.tpl.php * * @ingroup theme_preprocess */ function bootstrap_preprocess_bootstrap_panel(&$variables) { $element =& $variables['element']; // Set the element's attributes. element_set_attributes($element, array('id')); // Retrieve the attributes for the element. $attributes =& _bootstrap_get_attributes($element); // Add panel and panel-default classes. $attributes['class'][] = 'panel'; $attributes['class'][] = 'panel-default'; // states.js requires form-wrapper on fieldset to work properly. $attributes['class'][] = 'form-wrapper'; // Handle collapsible panels. $variables['collapsible'] = FALSE; if (isset($element['#collapsible'])) { $variables['collapsible'] = $element['#collapsible']; } $variables['collapsed'] = FALSE; if (isset($element['#collapsed'])) { $variables['collapsed'] = $element['#collapsed']; // Remove collapsed class since we only want it to apply to the inner element if ($index = array_search('collapsed', $attributes['class'])) { unset($attributes['class'][$index]); $attributes['class'] = array_values($attributes['class']); } } // Force grouped fieldsets to not be collapsible (for vertical tabs). if (!empty($element['#group'])) { $variables['collapsible'] = FALSE; $variables['collapsed'] = FALSE; } // Collapsible elements need an ID, so generate one for the fieldset's inner element. if ($variables['collapsible']) { // Generate an ID for the outer element if necessary. if (!isset($element['#id'])) { $element['#id'] = drupal_html_id('bootstrap-panel'); } $variables['id_inner'] = drupal_html_id($element['#id'] . '-inner'); } $variables['target'] = NULL; if (isset($element['#id'])) { $attributes['id'] = $element['#id']; if (isset($variables['id_inner'])) { $variables['target'] = '#' . $variables['id_inner']; } } // Build the panel content. $variables['content'] = $element['#children']; if (isset($element['#value'])) { $variables['content'] .= $element['#value']; } // Iterate over optional variables. $keys = array('description', 'prefix', 'suffix', 'title'); foreach ($keys as $key) { $variables[$key] = !empty($element["#{$key}"]) ? $element["#{$key}"] : FALSE; } // Add the attributes. $variables['attributes'] = $attributes; }
/** * Returns HTML for a button form element. * * @param $variables * An associative array containing: * - element: An associative array containing the properties of the element. * Properties used: #attributes, #button_type, #name, #value. * * @ingroup themeable */ function Cancilleria_button($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type'] . ' Cancilleria_button'; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
function blogbuzz_button($vars) { $element = $vars['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } return '<span class="button"><input' . drupal_attributes($element['#attributes']) . ' /></span>'; }
/** * Add Bootstrap classes to button elements. */ function gavias_laikafood_button($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'btn-primary btn form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
function drupal_13584_button($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type'] . ' free-templates-lt-button'; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } return '<span class="free-templates-lt-button-wrapper">' . '<span class="free-templates-lt-button-l"></span>' . '<span class="free-templates-lt-button-r"></span>' . '<input' . drupal_attributes($element['#attributes']) . ' />' . '</span>'; }
/** * Theme function implementation for myu_textfield_login_pass. */ function myu_myu_textfield_login_pass($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'password'; element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength')); _form_set_class($element, array('form-text')); $output = '<label class="control-label visible-ie8 visible-ie9">Username</label><div class="input-icon"><i class="fa fa-lock"></i>'; $output .= '<input' . drupal_attributes($element['#attributes']) . ' />'; $output .= '</div>'; return $output; }
/** * Theme button. Override AT Core because it screws with Views. */ function adaptivetheme_admin_button($vars) { $element = $vars['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
function opcaim_select($variables) { $element = $variables ['element']; element_set_attributes($element, array('id', 'name', 'size')); _form_set_class($element, array('form-select')); _form_set_class($divelement, array('form-select styled-select')); if (in_array('error', $element ['#attributes']['class'])) { _form_set_class($divelement, array('errorCustomSelect')); } return '<select' . drupal_attributes($element ['#attributes']) . '>' . form_select_options($element) . '</select>'; }
function analytics_portal_password($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'password'; element_set_attributes($element, array('id', 'name', 'size', 'maxlength')); _form_set_class($element, array('form-text', 'form-control')); $output = ''; // login form adding glyphicon. if ($element['#name'] == 'pass') { $output = '<span class="input-group-addon"><span class="glyphicon glyphicon-eye-close"></span></span>'; } return $output . '<input' . drupal_attributes($element['#attributes']) . ' />'; }
/** * Implements theme_button(). */ function nprdd_ui_button($vars) { $element = $vars['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } // Add class to pull in Foundation stuff. $element['#attributes']['class'][] = 'button'; return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
/** * Returns HTML for a form. * * @param $variables * An associative array containing: * - element: An associative array containing the properties of the element. * Properties used: #action, #method, #attributes, #children * * @ingroup themeable */ function ofen_form($variables) { $element = $variables['element']; if (isset($element['#action'])) { $element['#attributes']['action'] = drupal_strip_dangerous_protocols($element['#action']); } element_set_attributes($element, array('method', 'id')); if (empty($element['#attributes']['accept-charset'])) { $element['#attributes']['accept-charset'] = "UTF-8"; } // CHANGED: Anonymous DIV to satisfy XHTML compliance. // return '<form' . drupal_attributes($element['#attributes']) . '><div>' . $element['#children'] . '</div></form>'; return '<form' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</form>'; }
/** * Overrides theme_button(). */ function expressadmin_button($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } $element['#attributes']['class'][] = 'btn'; // Colorize button. _expressadmin_colorize_button($element); return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
/** * Implements hook_preprocess_button(). */ function bootstrap_preprocess_button(&$vars) { $element =& $vars['element']; // Set the element's attributes. element_set_attributes($element, array('id', 'name', 'value', 'type')); // Add the base Bootstrap button class. $element['#attributes']['class'][] = 'btn'; // Colorize button. _bootstrap_colorize_button($element); // Add in the button type class. $element['#attributes']['class'][] = 'form-' . $element['#button_type']; // Ensure that all classes are unique, no need for duplicates. $element['#attributes']['class'] = array_unique($element['#attributes']['class']); }
function nomad_password($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'password'; element_set_attributes($element, array('id', 'name', 'size', 'maxlength')); _form_set_class($element, array('form-text', 'form-control')); $output = '<input' . drupal_attributes($element['#attributes']) . ' />'; if ($element['#name'] == 'pass') { $prefix1 = '<div class="input-group margin-bottom-sm"><span class="input-group-addon"><i class="fa fa-lock fa-fw"></i></span>'; $suffix1 = "</div>"; $output = $prefix1 . $output . $suffix1; } return $output; }
/** * Overwrite theme_button() */ function foundation_button($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } //custom class $element['#attributes']['class'][] = 'button'; $element['#attributes']['class'][] = 'small'; $element['#attributes']['class'][] = 'radius'; return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
/** * Overrides theme_button(). */ function bootstrap_button($variables) { $element = $variables['element']; $label = $element['#value']; element_set_attributes($element, array('id', 'name', 'value', 'type')); // If a button type class isn't present then add in default. $button_classes = array('btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn-link'); $class_intersection = array_intersect($button_classes, $element['#attributes']['class']); if (empty($class_intersection)) { $element['#attributes']['class'][] = 'btn-default'; } // Add in the button type class. $element['#attributes']['class'][] = 'form-' . $element['#button_type']; // This line break adds inherent margin between multiple buttons. return '<button' . drupal_attributes($element['#attributes']) . '>' . $label . "</button>\n"; }
function smooth_form($variables) { $element = $variables['element']; if (isset($element['#action'])) { $element['#attributes']['action'] = drupal_strip_dangerous_protocols($element['#action']); } element_set_attributes($element, array('method', 'id')); if ($element['#form_id'] == 'search_block_form') { $output = '<div class="search-text">' . "\n" . '<span>' . t('SEARCH') . '</span>' . "\n"; $output .= '<form' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</form>' . "\n"; $output .= '</div>'; return $output; } else { // Anonymous DIV to satisfy XHTML compliance. return '<form' . drupal_attributes($element['#attributes']) . '><div>' . $element['#children'] . '</div></form>'; } }
/** * theme radio - support icons */ function subtpl_radio($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'radio'; element_set_attributes($element, array('id', 'name', '#return_value' => 'value')); if (!isset($element['#id'])) { $id = 'radio-' . rand(0, 1000); $element['#id'] = $id; $element['#attributes']['id'] = $id; } if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) { $element['#attributes']['checked'] = 'checked'; } $label = isset($element['#title']) && $element['#title_display'] == 'after' ? '' : '<label for="' . $element['#id'] . '"></label>'; _form_set_class($element, array('form-radio')); $icon = substr($element['#return_value'], 0, 5) == "icon-" ? '<span class="iblock icon ' . $element['#return_value'] . '"> </span>' : ''; return $icon . '<input' . drupal_attributes($element['#attributes']) . ' />' . $label; }
/** * Pre-processes variables for the "button" theme hook. * * See theme function for list of available variables. * * @see bootstrap_button() * @see theme_button() * * @ingroup theme_preprocess */ function bootstrap_preprocess_button(&$vars) { $element =& $vars['element']; // Drupal buttons should be of type 'submit'. // @see https://www.drupal.org/node/2540452 $element['#attributes']['type'] = 'submit'; // Set the element's other attributes. element_set_attributes($element, array('id', 'name', 'value')); // Add the base Bootstrap button class. $element['#attributes']['class'][] = 'btn'; // Add button size, if necessary. if ($size = bootstrap_setting('button_size')) { $element['#attributes']['class'][] = $size; } // Colorize button. _bootstrap_colorize_button($element); // Add in the button type class. $element['#attributes']['class'][] = 'form-' . $element['#button_type']; // Ensure that all classes are unique, no need for duplicates. $element['#attributes']['class'] = array_unique($element['#attributes']['class']); }
/** * Theme function implementation for simplenews_form_wrapper. */ function traveljordan_simplenews_form_wrapper($variables) { $element = $variables['element']; if (isset($element['#action'])) { $element['#attributes']['action'] = drupal_strip_dangerous_protocols($element['#action']); } element_set_attributes($element, array('method', 'id')); if (empty($element['#attributes']['accept-charset'])) { $element['#attributes']['accept-charset'] = "UTF-8"; } $output = '<form' . drupal_attributes($element['#attributes']) . '>'; $output .= '<div class="input-group input-group-lg">'; $output .= $variables['element']['#children']; $output .= '<span class="input-group-btn">'; $output .= '<button type="submit" class="btn btn-default">'; $output .= t('Subscribe'); $output .= '</button>'; $output .= '</span>'; $output .= '</div>'; $output .= '</form>'; return $output; }
/** * Overrides theme_textfield(). */ function evolve_textfield($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'text'; element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength')); _form_set_class($element, array('form-text')); $output = '<input' . drupal_attributes($element['#attributes']) . ' />'; $extra = ''; if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) { drupal_add_library('system', 'drupal.autocomplete'); $element['#attributes']['class'][] = 'form-autocomplete'; $attributes = array(); $attributes['type'] = 'hidden'; $attributes['id'] = $element['#attributes']['id'] . '-autocomplete'; $attributes['value'] = url($element['#autocomplete_path'], array('absolute' => TRUE)); $attributes['disabled'] = 'disabled'; $attributes['class'][] = 'autocomplete'; $output = '<div class="input-group">' . $output . '<span class="input-group-addon">' . _bootstrap_icon('refresh') . '</span></div>'; $extra = '<input' . drupal_attributes($attributes) . ' />'; } return $output . $extra; }
/** * Returns HTML for a fieldset. */ function at_commerce_fieldset($vars) { $element = $vars['element']; element_set_attributes($element, array('id')); _form_set_class($element, array('form-wrapper')); $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>'; // add a class to the fieldset wrapper if a legend exists, in some instances they do not $class = "without-legend"; if (!empty($element['#title'])) { // Always wrap fieldset legends in a SPAN for CSS positioning. $output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>'; // Add a class to the fieldset wrapper if a legend exists, in some instances they do not $class = 'with-legend'; } $output .= '<div class="fieldset-wrapper ' . $class . '">'; if (!empty($element['#description'])) { $output .= '<div class="fieldset-description">' . $element['#description'] . '</div>'; } $output .= $element['#children']; if (isset($element['#value'])) { $output .= $element['#value']; } $output .= '</div>'; $output .= "</fieldset>\n"; return $output; }
/** * Overrides theme_fieldset(). * * Add another div wrapper around fieldsets for styling purposes. */ function commons_beehive_fieldset($variables) { $element = $variables['element']; element_set_attributes($element, array('id')); _form_set_class($element, array('form-wrapper')); $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>'; if (!empty($element['#title'])) { // Always wrap fieldset legends in a SPAN for CSS positioning. $output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>'; } $output .= '<div class="fieldset-wrapper">'; if (!empty($element['#description'])) { $output .= '<div class="fieldset-description">' . $element['#description'] . '</div>'; } $output .= $element['#children']; if (isset($element['#value'])) { $output .= $element['#value']; } $output .= '</div>'; $output .= "</fieldset>\n"; return '<div class="fieldset-outer-wrapper">' . $output . '</div>'; }
/** * Implements theme_select(). */ function foundation_access_select($variables) { $element = $variables['element']; element_set_attributes($element, array('id', 'name', 'size')); _form_set_class($element, array('form-select')); return '<select' . drupal_attributes($element['#attributes']) . '>' . _foundation_access_form_select_options($element) . '</select>'; }
<?php $element = $variables['element']; element_set_attributes($element, array('id', 'name', 'cols', 'rows')); _form_set_class($element, array('form-control', 'form-item')); $wrapper_attributes = array('class' => array('form-textarea-wrapper')); // When editing a block textarea, Ckeditor will remove some HTML code from the // textarea. This will remove the Ckeditor module/library from the form so // we can maintain the HTML code entered in the textarea. if (!empty($element['#title']) && $element['#title'] == 'Block body') { $path = explode('/', current_path()); $manage_block = ($path[2] = 'block' && $path[3] == 'manage') ? TRUE : FALSE; if ($manage_block && isset($element['#pre_render'])) { foreach ($element['#pre_render'] as $key => $pre_render) { if ($pre_render == 'ckeditor_pre_render_text_format') { foreach ($element['#attributes']['class'] as $class_key => $class) { if ($class == 'ckeditor-mod') { unset($element['#attributes']['class'][$class_key]); } } foreach ($element['#attached']['css'] as $attached_css_key => $attached_css) { if ($attached_css == 'sites/all/modules/contrib/ckeditor/css/ckeditor.editor.css') { if (count($element['#attached']['css']) == '1') { unset($element['#attached']['css']); } else { unset($element['#attached']['css'][$attached_css_key]); } } } unset($element['#pre_render'][$key]); }
/** * Returns HTML for a button form element. */ function agency_whitesite_button($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'submit'; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type']; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } return '<button' . drupal_attributes($element['#attributes']) . ' />' . $element['#attributes']['value'] . '</button>'; }
function townsquare_bootstrap_button($variables) { $element = $variables['element']; $type = strtolower($element['#button_type']); switch ($type) { case 'submit': case 'reset': case 'button': break; default: $type = 'submit'; break; } $element['#attributes']['type'] = $type; element_set_attributes($element, array('id', 'name', 'value')); $element['#attributes']['class'][] = 'form-' . $element['#button_type']; $element['#attributes']['class'][] = 'btn'; if (!empty($element['#attributes']['disabled'])) { $element['#attributes']['class'][] = 'form-button-disabled'; } $title = isset($element['#button_text']) ? $element['#button_text'] : $element['#value']; return '<button' . drupal_attributes($element['#attributes']) . '>' . $title . '</button>'; }
/** * Overides theme_radio */ function innovation_radio($variables) { $element = $variables['element']; $element['#attributes']['type'] = 'radio'; element_set_attributes($element, array('id', 'name', '#return_value' => 'value')); if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) { $element['#attributes']['checked'] = 'checked'; } _form_set_class($element, array('form-radio')); return '<input' . drupal_attributes($element['#attributes']) . ' /><span class="outer-wrap"><i class="fa fa-circle"></i></span>'; }