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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java 取余和取模运算之间的区别「建议收藏」

    java 取余和取模运算之间的区别「建议收藏」转自lee371042https://blog.csdn.net/lee371042/article/details/102553342packageOperator;importjava.math.BigInteger;/***假如有两个数:*amod(b)与a%b,b为正整数,*一种叫a对b取模,另一个叫a对b取余,两种叫法有什么区别呢?*通常情况下,取模运算也叫取余运算,*它们返回的结果都是一个数对另一个数的余数,**区别在于当a是一

    2022年6月3日
    35
  • vb教程编程实例详解pdf_vb程序设计教程答案第四版

    vb教程编程实例详解pdf_vb程序设计教程答案第四版实验8-7在教学篇例8.7的基础上增加“修改确定”按钮以及用于定位记录的按钮面板,如图2.8.5所示,并编写时间过程。解题,代码如下:先建立标准模块,代码是:TypestudtypeiNoAsIntegerstrNameAsString*20strSexAsString*1sMarkAsSingleEndType…

    2022年10月7日
    2
  • Java中的JPA是什么意思?「建议收藏」

    Java中的JPA是什么意思?「建议收藏」JPA(JavaPersistenceAPI),Java持久层API。它可以通过注解(JDK5.0)或者XML的方式描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中。它为POJO提供持久化标准规范,Hibernate3.2+、TopLink10.1.3以及OpenJPA都提供了JPA的实现它的总体思想和现有Hibernate、TopLink、JDO等ORM框架大体一致。它包括以下3方面的技术:(1)ORM映射元数据JPA支持XML和JDK5.0注解两种元.

    2022年6月29日
    31
  • pycharm 3.2激活码 2022【在线注册码/序列号/破解码】

    pycharm 3.2激活码 2022【在线注册码/序列号/破解码】,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月19日
    67
  • 关于Heap free block xxxxxxxx modified at xxxxxxxxx after is was freed

    关于Heap free block xxxxxxxx modified at xxxxxxxxx after is was freed程序崩溃了,日志中的提示是:Heapfreeblockxxxxxxxxmodifiedatxxxxxxxxxafteriswasfreed和百度快乐地玩耍了很久,得知造成这种错误的原因可能是野指针,即指针指向的内存位置不是你想要的东西,它很可能已经被删除或者移动了。事情是这样发生的:我在逻辑中使用了三个List(AllSpriteList,FriendList,Enemy

    2022年8月22日
    21
  • SqlTransaction的解析

    SqlTransaction的解析SqlTransaction类表示要在SQLServer数据库中处理的Transact-SQL事务。无法继承此类应用程序通过在SqlConnection对象上调用BeginTransaction来创建SqlTransaction对象。对SqlTransactio

    2022年5月1日
    47

发表回复

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

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