Drupal7模块multiselect使用
Drupal二次开发的时候,我们时常要使用到多选列表,但是官方默认的多选下拉列表,是在不敢恭维如下图所示:

不过难看不可怕,Drupal有两万第三方模块做支撑,只有你想不到,没有找不到的。
功夫不负有心人,终于找到一款相貌极佳的module。于是拿过来使用,切看我慢慢道来,该去如何使用它。
第一:去官网下载模块,安装。

第二:安装完毕,接下来就要使用到Form API开发中去
/**
* hook_menu().
* @author masx
*/
function front_menu(){ $items['formexample'] = array(
'title' => 'View the sample form',
'page callback' => 'drupal_get_form',
'page arguments' => array('front_nameform'),
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM
);
return $items;
}
/**
* Define a form. 构造表单
*/
function front_nameform() {
$form['user_name'] = array(
'#title' => t('Your Name'),
'#type' => 'textfield',
'#description' => t('Please enter your name.'),
);
$form['selected'] = array(
'#type' => 'select',
'#title' => t('Selected'),
'#multiple' => 3,
'#options' => array(
0 => t('驴儿'),
1 => t('牛儿'),
2 => t('狗儿'),
3 => t('猫儿'),
4 => t('驴儿'),
5 => t('牛儿'),
),
'#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
return $form;
}
/**
* Handle post-validation form submission.处理表单
*/
function front_nameform_submit($form, &$form_state) {
$name = $form_state['values']['user_name'];
drupal_set_message(t('Thanks for filling out the form, %name',
array('%name' => $name)));}
}
第三:显示效果

Drupal7模块multiselect使用的更多相关文章
- (转) 转换Drupal7模块到Drupal8
转载地址:http://verynull.com/2015/11/02/Converting-7-x-modules-to-8-x/ 本节主要介绍如何把drupal7的模块转化为drupal8.参考资 ...
- drupal7 boost模块为登录用户提供缓存
这段时间研究Drupal7的缓存相关,看了好多资料,都提到了boost和authcache两个模块,今天来说一下boost. 具体的下载安装,配置等,官网写的听清楚,boost模块地址 ,安装配置方法 ...
- drupal7整合Discuz康盛UC用户中心ucenter,ucuser模块
drupal7整合Discuz康盛UC用户中心ucenter,ucuser模块Drupal7整合UC用户心的模块,ucenter,康盛这个用户中心我就不多说了哈.参考了以前不知在哪里下载的一个drup ...
- Drupal7所见即所得模块CKEditor
初学Drupal(7.26),刚好遇到一个需要用到CKEditor模块的项目,于是就摸索着把它给装上了. 图片上传出问题 回到Drupal7的管理页面后刚好发现了对于CKEditor的“状态报告”(错 ...
- drupal7 开发自定义上传、下载模块的上传功能
关键点有两个:1.在页面上显示出上传的控件,2.代码实现文件上传到服务器的功能 一.显示控件: 先来看关键点1: 实现页面显示出上传控件, 关键代码: $form['my_file_field'] = ...
- drupal7为admin/config页面添加自己开发的模块
1.实现显示模块 //admin/config配置页面添加journal块 $items['admin/config/journal'] = array(//注意格式为'admin/config/模块 ...
- 【第196期】Drupal7 Features模块与 Drupal8 Configuration Management 模块对比
Drupal 8 最好和最受欢迎的部分之一是新的配置管理系统. 该系统使开发人员很容易将配置导出到代码中.在此之前,开发人员不得不依赖于由Features.Strongarm.UUID.Feature ...
- drupal7 获取profile2模块自定义字段的值
$user=user_load($uid); $student=profile2_load_by_user($user,'student'); 这个函数官方有文档,通过用户对象返回用户的profile ...
- drupal7 的核心模块
核心模块 Drupal 7 block Block(区块)模块提供了与区块相关的功能,通过区块可将内容放置在网站不同区域.Block模块是Drupal的基础模块之一,不能被禁用.它是通过单独的区块管理 ...
随机推荐
- Android Spinner 下拉列表
private Spinner spinner ; private List<String> list ; private ArrayAdapter< ...
- java后台开发- NOTE
2015-1-6: IDEA servlet-api.jar idea从14升级到15后,发现 import javax.servlet.AsyncContext; 找不到,右击工程,open mod ...
- discuz函数dgmdate
function dgmdate($timestamp, $format = 'dt', $timeoffset = '9999', $uformat = '') { global $_G; $for ...
- openNebula images
- Android的UI两大基石
说到Android的UI就不得不从一切的开始View开始说. 让我们从Android Developer上的View的Overview和UI Overview来开始吧. Cla ...
- python 类型转换函数
python提供了一些可将某个值从一种类型转换为另一种类型的内置函数. 1. int函数可以把任何可以转换为整型的值转换为整型.int可以将浮点数转换为整数,但不会做四舍五入操作,而是直接丢弃小数部分 ...
- 解决Android中TextView首行缩进的问题
方式一:(推荐) setText("\u3000\u3000"+xxxxx); 方式二:这种方式不同分辨率会有问题 setText(""+xxxxx); 半角: ...
- C. Table Decorations(Codeforces Round 273)
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- IOS7 position:fixed 定位问题
在IOS7下position:fixed定位会出一些bug. 输入框 focus 状态下 fixed会随之改变.参见该页面详细描述(http://www.cnblogs.com/zhangdaipin ...
- jquery数字验证大小比较
$("#rewardForm").validate({ rules: { "reward": { ...