我有一个entityform块,我想在其输入中添加bootstrap类! 我该怎么做?我应该编辑哪些文件?
我在drupal.org上使用最新版本的entityform和entity block
谢谢
答案 0 :(得分:2)
您需要将这些功能添加到主题文件夹中的template.php文件中(将THEME_NAME替换为您主题的实际名称):
function THEME_NAME_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'));
$element['#attributes']['class'][] = 'form-control';
$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';
$extra = '<input' . drupal_attributes($attributes) . ' />';
}
$output = "<div class='input-wrapper'>";
$output .= '<input' . drupal_attributes($element['#attributes']) . ' />';
$output .= "</div>";
return $output . $extra;
}
function THEME_NAME_button($variables) {
$element = $variables['element'];
$element['#attributes']['type'] = 'submit';
element_set_attributes($element, array('id', 'name', 'value'));
$element['#attributes']['class'][] = 'form-' . $element['#button_type'];
$element['#attributes']['class'][] = 'btn btn-default';
if (!empty($element['#attributes']['disabled'])) {
$element['#attributes']['class'][] = 'form-button-disabled';
}
$value = $element['#attributes']["value"];
if( isset($element['#attributes']["button-type"]) && $element['#attributes']["button-type"] == "search" ) {
$value = $element['#attributes']["icon"];
unset($element['#attributes']["icon"]);
}
return '<button' . drupal_attributes($element['#attributes']) . '>' . $value . '</button>';
}
function THEME_NAME_select($variables) {
$element = $variables['element'];
element_set_attributes($element, array('id', 'name', 'size'));
_form_set_class($element, array('form-select', 'form-control'));
return '<select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
}
这些函数将添加按钮,文本字段和选择输入类型所需的类。此外,您还需要在主题中包含引导程序文件。