Drupal表单实例教程[通俗易懂]

Drupal表单实例教程[通俗易懂]Drupal表单实例教程form_example.info文件name=Formexampledescription=ExamplesofusingtheDrupalFormAPI.package=Examplemodulescore…

大家好,又见面了,我是你们的朋友全栈君。

Drupal表单实例教程

form_example.info文件

name = Form example description = Examples of using the Drupal Form API. package = Example modules core = 7.x files[] = form_example.test

form_example.module文件

<?php /** * @file * Examples demonstrating the Drupal Form API. */ /** * @defgroup form_example Example: Form API * @ingroup examples * @{ * Examples demonstrating the Drupal Form API. * * The Form Example module is a part of the Examples for Developers Project * and provides various Drupal Form API Examples. You can download and * experiment with this code at the * @link http://drupal.org/project/examples Examples for Developers project page. @endlink */ /** * Implements hook_menu(). * * Here we set up the URLs (menu entries) for the * form examples. Note that most of the menu items * have page callbacks and page arguments set, with * page arguments set to be functions in external files. */ function form_example_menu() { $items = array(); $items['examples/form_example'] = array( 'title' => 'Form Example', 'page callback' => 'form_example_intro', 'access callback' => TRUE, 'expanded' => TRUE, ); $items['examples/form_example/tutorial'] = array( 'title' => 'Form Tutorial', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_1'), 'access callback' => TRUE, 'description' => 'A set of ten tutorials', 'file' => 'form_example_tutorial.inc', 'type' => MENU_NORMAL_ITEM, ); $items['examples/form_example/tutorial/1'] = array( 'title' => '#1', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_1'), 'access callback' => TRUE, 'description' => 'Tutorial 1: Simplest form', 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/2'] = array( 'title' => '#2', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_2'), 'access callback' => TRUE, 'description' => 'Tutorial 2: Form with a submit button', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/3'] = array( 'title' => '#3', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_3'), 'access callback' => TRUE, 'description' => 'Tutorial 3: Fieldsets', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/4'] = array( 'title' => '#4', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_4'), 'access callback' => TRUE, 'description' => 'Tutorial 4: Required fields', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/5'] = array( 'title' => '#5', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_5'), 'access callback' => TRUE, 'description' => 'Tutorial 5: More element attributes', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/6'] = array( 'title' => '#6', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_6'), 'access callback' => TRUE, 'description' => 'Tutorial 6: Form with a validate handler', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/7'] = array( 'title' => '#7', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_7'), 'access callback' => TRUE, 'description' => 'Tutorial 7: Form with a submit handler', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/8'] = array( 'title' => '#8', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_8'), 'access callback' => TRUE, 'description' => 'Tutorial 8: Basic multistep form', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', ); $items['examples/form_example/tutorial/9'] = array( 'title' => '#9', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_9'), 'access callback' => TRUE, 'description' => 'Tutorial 9: Form with dynamically added new fields', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', 'weight' => 9, ); $items['examples/form_example/tutorial/10'] = array( 'title' => '#10', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_tutorial_10'), 'access callback' => TRUE, 'description' => 'Tutorial 11: Form with file upload', 'type' => MENU_LOCAL_TASK, 'file' => 'form_example_tutorial.inc', 'weight' => 10, ); $items['examples/form_example/states'] = array( 'title' => '#states example', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_states_form'), 'access callback' => TRUE, 'description' => 'How to use the #states attribute in FAPI', 'file' => 'form_example_states.inc', ); $items['examples/form_example/wizard'] = array( 'title' => 'Extensible wizard example', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_wizard'), 'access callback' => TRUE, 'description' => 'A general approach to a wizard multistep form.', 'file' => 'form_example_wizard.inc', ); $items['examples/form_example/element_example'] = array( 'title' => 'Element example', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_example_element_demo_form'), 'access callback' => TRUE, 'file' => 'form_example_elements.inc', 'weight' => 100, ); return $items; } /** * Page callback for our general info page. */ function form_example_intro() { $markup = t('The form example module provides a tutorial, extensible multistep example, an element example, and a #states example'); return array('#markup' => $markup); } /** * Implements hook_help(). */ function form_example_help($path, $arg) { switch ($path) { case 'examples/form_example/tutorial': // TODO: Update the URL. $help = t('This form example tutorial for Drupal 7 is the code from the <a href="http://drupal.org/node/262422">Handbook 10-step tutorial</a>'); break; case 'examples/form_example/element_example': $help = t('The Element Example shows how modules can provide their own Form API element types. Four different element types are demonstrated.'); break; } if (!empty($help)) { return '<p>' . $help . '</p>'; } } /** * Implements hook_element_info(). * * To keep the various pieces of the example together in external files, * this just returns _form_example_elements(). */ function form_example_element_info() { require_once('form_example_elements.inc'); return _form_example_element_info(); } /** * Implements hook_theme(). * * The only theme implementation is by the element example. To keep the various * parts of the example together, this actually returns * _form_example_element_theme(). */ function form_example_theme($existing, $type, $theme, $path) { require_once('form_example_elements.inc'); return _form_example_element_theme($existing, $type, $theme, $path); } /** * @} End of "defgroup form_example". */

转载于:https://my.oschina.net/Qm3KQvXRq/blog/165546

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/141689.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • jmeter正则表达式提取器怎么使用_jmeter的正则表达式

    jmeter正则表达式提取器怎么使用_jmeter的正则表达式转载:https://www.cnblogs.com/du-hong/p/13217399.html允许用户使用正则表达式从服务器响应中提取值。作为后处理器,此元素将在其范围内的每个Sample请求之后执行,应用正则表达式,提取请求的值,生成模板字符串,并将结果存储到给定的变量名称中。1、我们先来看看这个正则表达式提取器长得是啥样子,路径:线程组>添加>后置处理器>正则表达式提取器,如下图所示:2、关键参数说明如下:Name:名称,可以随意设置,甚至为空;Comme

    2022年9月10日
    0
  • Dreamweaver CS6安装教程

    Dreamweaver CS6安装教程一.解压二.安装点击忽略

    2022年6月9日
    39
  • flash cookie的制作和使用例子详解 一

    flash cookie的制作和使用例子详解 一flashcookie是什么,有什么作用,这些不做介绍,可以在网上搜,这里主要是做一个制作和使用flashcookie的例子要使用flashcookie首先要制作一个swf的flash文件,然后在页面才能调用。flash的制作,这里我们就用adobeflashcs5,这个工具网上一搜就可以找到下载地址打开后界面如下图所示,[img]http://dl2.iteye…

    2022年7月14日
    16
  • 简单网页的制作_html简单网页制作

    简单网页的制作_html简单网页制作前言:虽然现在有很多网页模板可以套用,但是不写代码就永远不能进步!简单介绍:HTML是一种超文本标记语言,简单来说就是用来做网页的,没有别的脚本语言的加持下只能做静态网页。在有其它脚本语言JavaScript(JS)和PHP语言的加持下就可以做动态网页,甚至可以做耗费精力和时间的响应式网站。刚才说的静态网页、动态网页和响应式网站显然都是后话了,到后边还有伪静态网页,这些到后面再讲。HTML编译器:Dreamweaver和WebStorm写一个简单网页可以先用记事本废话不多

    2022年10月13日
    0
  • linux mysql重置密码_linux系统重置

    linux mysql重置密码_linux系统重置linux的Mysql重置密码(1)先修改配置文件/etc/my.cnf令MySQL跳过登录时的权限检验,在[mysqld]下加入一行:skip-grant-tables(2)重启MySQLsystemctlrestartmysqld(3)免密码登录MySQLskip-grant-tables(4)mysql客户端执行如下命令,修改root密码mysql>usemysql;MySQL>updatemysql.usersetauthentication_s

    2022年10月15日
    0
  • Tracert 工作原理[通俗易懂]

    Tracert 工作原理[通俗易懂]Tracert工作原理通过向目标发送不同IP生存时间(TTL)值的“Internet控制消息协议(ICMP)”回应数据包,Tracert诊断程序确定到目标所采取的路由。要求路径上的每个路由器在转发数据包之前至少将数据包上的TTL递减1。数据包上的TTL减为0时,路由器应该将“ICMP已超时”的消息发回源系统。Tracert先发送T…

    2022年9月14日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号