zoukankan      html  css  js  c++  java
  • 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)));}
    }

          第三:显示效果


  • 相关阅读:
    android 14 进度条和拖动条
    android 13 5种click事件不同实现方式 比较
    android 12 click事件的不同实现方式
    android 11 模拟onclick 事件
    android 10 事件
    android 09
    android 08 AndroidManifest.xml
    android 07 22 23没看
    Linux常用命令last的使用方法详解
    Linux TOP命令 按内存占用排序和按CPU占用排序
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3327570.html
Copyright © 2011-2022 走看看