Drupal Form API_iteye_3753的博客-程序员宝宝

Now, form generation engine collects the information about formelements bycalling<wbr><em>element_info()</em><wbr>function.This in turn calls<em>hook_element()</em>, which might beimplemented by other modules. We can use this hook to create ourown specialized element types, eg textbox which only takes numericinput.</wbr></wbr>

Now engine know the definition of all element type, so it next itwill look for form validation function. The form validationfunction to use can be specified in any of theforms<wbr><em>#validate</em>,or<em>formID_validate()<wbr></wbr></em>or<wbr><em>#base_validate()</em>.<wbr><em>#base</em><wbr>isthe value that you specify with the form array.</wbr></wbr></wbr></wbr>

Engine will look for submit function to which the form will besubmitted. They can be specified asvalue<wbr><em>#submit<wbr></wbr></em>for key,or<em>formID_submit()</em><wbr>functionor<wbr><em>#base_submit()</em><wbr>function.Once it gets the submit function for the form itcalls<wbr><em>hook_form_alter()</em><wbr>togive any module which wants to change the form. Basically it’s ourtime to modify someone else’s form to add or remove the inputfields and/or descriptions.</wbr></wbr></wbr></wbr></wbr></wbr>

Form elements are now declared in array fashion, with thehierarchical structure of the form elements themselves as arrayelements (which can be nested), and each form elementsproperties/attributes listed as array elements in key/valuepairs--the key being the name of the property/attribute, and thevalue being the value of the property/attribute. For example,here's how to go about constructing a textfield formelement:

drupal_get_form<wbr>doesthe following:</wbr>

<wbr></wbr>

  • Starts the entire form-building process by gettingthe<wbr><code style="border:0px; background-color:rgb(246,246,242); font-size:0.923em; margin:0px; padding:1px; vertical-align:baseline; font-family:'Bitstream Vera sans Mono',Monaco,'Lucida Console',monospace; line-height:1.5em; white-space:pre-wrap">$form</code><wbr>fromthe builder function</wbr></wbr>
  • Translates the<wbr><code style="border:0px; background-color:rgb(246,246,242); font-size:0.923em; margin:0px; padding:1px; vertical-align:baseline; font-family:'Bitstream Vera sans Mono',Monaco,'Lucida Console',monospace; line-height:1.5em; white-space:pre-wrap">$form['name']</code><wbr>itemsinto actual form elements</wbr></wbr>
  • Performs any validation and "clean-up" that needs to be done, andcalls custom validation functions if declared
  • Submits the form if a submit function is declared, and the form hasbeen submitted
  • Calls any custom theming functions that have been declared
  • Returns an HTML string which contains the actual form.
The preferred method of submitting forms with the API is throughthe use of a form submit function. This has the same namingconvention and arguments as the validation function,except<wbr></wbr> _submit <wbr>isappended instead. Any forms which are submitted from a buttonof<wbr></wbr></wbr> type=> 'submit' <wbr>willbe passed to their corresponding submit function if it isavailable. This method is more secure thangrabbing<wbr></wbr></wbr> $_POST['edit'] <wbr>andusing a switch statement.</wbr>


版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/iteye_3753/article/details/82451496

智能推荐

Android 操作SQLite基本用法_程思扬的博客-程序员宝宝_手机操作sqlite

本文内容转自荣耀王者的博客一.SQLite的介绍1.SQLite简介SQLite是一款轻型的数据库,是遵守ACID的关联式数据库管理系统,它的设计目标是嵌入 式的,而且目前已经在很多嵌入式产品中使用了它,它占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存就够了。它能够支持 Windows/Linux/Unix等等主流的操作系统,同时能够跟很多程序语言相结合,比如Tcl、PHP、Ja...

VS2008/VS2010安装时提示VC++9.0 Runtime安装失败问题的解决方法_CoderTom的博客-程序员宝宝

查了一下,大概有一下几种解决方法:   1)http://blog.csdn.net/zlqqhs/article/details/8821608   2)https://dotblogs.com.tw/johnny/archive/2010/07/16/16587.aspx   3)http://wenku.baidu.com/link?url=-24ZUuY0AhzvtJmC_FL

Linux学习-HaProxy_丢爸的博客-程序员宝宝_haproxy 统计页面

Nginx:反向代理 URI,代理后端某服务器HaProxyURL:提高缓存命中率HaProxy借助于OS上几种常见的技术来实现性能的最大化单进程、事件驱动模型显著降低了上下文切换的开销及内存占用O(1)事件检查器(event checker)允许其在高并发连接中对任何连接的任何事件实现即时探测在任何可用的情况下,单缓冲(single buffering)机制能以不复制任何数据的方式完成读写操作,这会节约大量的CPU时钟周期及内存带宽借助于Linux2.6及以上版本的splice()系统调

C语言结构体成员有函数的定义与使用_威唯的博客-程序员宝宝_结构体中定义一个成员函数

```c#include &lt;stdio.h&gt;typedef int (*FunHandle)(int, int); //定义 指向函数的指针 struct Example{ int a; int b; FunHandle fun; //函数作为结构体成员};int add(int, int);int main(){ struct Example ex; int r; ex.a = 1; ex.b = 2;.

AT24C16 读写注意点_kuniqiw的博客-程序员宝宝_at24c16

这篇文章介绍了AT24C16的页写、连续读、写保护功能:https://blog.csdn.net/liangbin414/article/details/88293321页写算法我是参考这篇文章的:https://acuity.blog.csdn.net/article/details/78550427?utm_m总的来说虽然最后也实现了,但eeprom里有的坑似乎也全被我踩遍了。从只能写一页大小,到可以页写,再到可以实现随机写,还是蛮曲折并且浪费了我不少时间的。废话不多讲,下面介绍下我最终...

随便推点

Android 自定义View绘制一个圆,属性动画 进行垂直平移_抱着回忆旅行的博客-程序员宝宝

效果创建一个类ClaViewpackage com.example.zklx2;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.util....

WEB程序的前后端数据交互流程_weixin_34361881的博客-程序员宝宝

说明我写这篇文章的目的其实是想科普一下基础的数据传输和交互流程,其实也就是写http协议相关的一些东西。而写这篇文章也主要是源于最近和长久以来很多人问的问题都是有关于这块的(可能问题并不是这么问,但是主要涉及到的根本原因还是这一块),所以我想写这篇文章也算是做一个科普,让大家在写前后端程序的时候,不会由于数据传输的问题而不知道怎么去解决bug。这篇我觉得算是一篇基础文章,本来想取个高大上的名字...

AMESim2017许可证错误_松礼礼的博客-程序员宝宝_amesim许可证服务器连接不上

AMESim2017出现许可证错误:rlm不能连接Tina在之前的安装包中找到LMS_RLM_server文档

jquery_一舟yz的博客-程序员宝宝

本文来自动力节点jquery,供复习使用文章目录介绍为什么[why]使用 jQueryDOM 对象获取 jQuery第一个例子DOM 对象和 jQuery 对象选择器基本选择器(id,class,标签)表单选择器过滤器基本过滤器表单对象属性过滤器函数第一组val(最常用)textattr第二组hideshowremoveemptyappendhtmleach事件定义元素监听事件on() 绑定事件AJAX$.ajax()$.get()$.post()使用 AJAX 级联查询介绍jQuery 是一款跨.

卷积神经网络(CNN)_weixin_33967071的博客-程序员宝宝

from  http://blog.jobbole.com/113819/?utm_source=blog.jobbole.com&amp;amp;utm_medium=relatedPosts 什么是卷积神经网络,它为何重要?卷积神经网络(也称作 ConvNets 或 CNN)是神经网络的一种,它在图像识别和分类等领域已被证明非常有效。 卷积神经网络除了为机器人和自动驾驶汽车的视觉助力之外,...

Sigma Grid 研究及使用_karlhell的博客-程序员宝宝

Sigma Grid 纯javascript,Sigma grid 用Ajax做grid展现并可实现数据的编辑,支持滚动表格及排序。它是非常强大的并且简单易用并且能整合php,asp.net,jsp,RoR研究版本:Sigma Grid 2.2Grid目录结构:grid|---&gt;calendar| |--calendar.js| |--calen...

推荐文章

热门文章

相关标签