Bootstrap 3,如何禁用自动添加的Glyphicon?

时间:2016-10-22 13:07:04

标签: drupal twitter-bootstrap-3

我在Drupal 8中使用Bootstrap(v3)。当我创建名为“搜索某事物”的按钮时,bootstrap会自动添加“搜索”字形。我做了一些网络搜索,但我没有找到如何“禁用”(或隐藏?)我的按钮的'search'auto-added glyphicon。

当我从Form Class自定义模块创建示例提交按钮时:

public function buildForm(array $form, FormStateInterface $form_state) {
...
$form['submit'] = [
  '#type' => 'button',
  '#value' => 'Search something',
];    

如果我转到有表格的页面,按钮会自动放大一个放大镜字形:

enter image description here

我想要显示没有任何字形的按钮,我该怎么做?我必须在我的按钮上添加一个课程吗?哪个?

谢谢!

2 个答案:

答案 0 :(得分:0)

以下是“glyphicon glyphicon-search”的示例代码。检查添加到按钮的类,它不能自动添加 - 没有任何魔力。

希望这会有所帮助..

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<p>normal button without Glyphicon icon: <span class="btn btn-default">button </span></p>

<p>Search icon: <span class="glyphicon glyphicon-search"></span></p>

<p>Search icon on a button:
  <button type="button" class="btn btn-default">
    <span class="glyphicon glyphicon-search"></span> Search
  </button>
</p>

<p>Search icon on a styled button:
  <button type="button" class="btn btn-info">
    <span class="glyphicon glyphicon-search"></span> Search
  </button>
</p>

答案 1 :(得分:0)

我成功将以下内容添加到表单元素中:

'#icon' => array('none'),

所以整个事情看起来像:

$form['submit'] = [
  '#type' => 'button',
  '#value' => 'Search something',
  '#icon' => array('none'),
];