惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
J
Java Code Geeks
雷峰网
雷峰网
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
S
Securelist
The Hacker News
The Hacker News
The Register - Security
The Register - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
AI
AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
博客园 - 司徒正美
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
U
Unit 42
V
V2EX
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
美团技术团队
小众软件
小众软件
F
Fortinet All Blogs

博客园 - jerry data

(转)三维管线自动建模工具PipelineCreator 招聘技巧一二 (转) python抓网页中文乱码问题 - jerry data - 博客园 星 ---- 谷村新司 (转载)arcgis flex api 访问 google 地图 arcgis flex api 访问 google 地图 iframe and margin - jerry data Difference method for Parse XML with C# PInvoke .NET ~ C++ how to call the member function?( C++ ) . or -> "con" function usage tip!! 转载 : flex3 中 Legend fontSize不起作用的bug解决 map service query result maxrecordcount Block development arcmap field calculator Michael F. Goodchild Talks about the Role of Volunteered Geographic Information in a Postmodern GIS World create user with custom profile 唐骏十年管理经验谈:管理者要学会让员工感动 mysql - tutorial 1
theme elements in the form - jerry data
jerry data · 2009-11-28 · via 博客园 - jerry data

2 methods

first one:

在template.php文件中加入override函数,函数名称的规则为themeName_type,例如simplegreen_textfield()。

function simplygreen_textfield()
{
$args = func_get_args();
$output = '<input type="text" value="jerry love cecy" size="35" id="edit-email" name="email" maxlength="128"/>';
return $output;
}

该方法全面覆盖原来的系统核心文件form.inc中的theme_textfield方法。在网站中的每一个textfield都是默认使用该函数render。

second one:使用模板的方法,该方法可以只针对某一个元素,而不影响其他的元素。

在构造$form数组时,为指定的元素指定theme模板。
function register_user_form()
{
$period = drupal_map_assoc(array(3600,10800,21600,32400,43200,86400),'format_interval');

$form['email'] = array('#type' => 'textfield','#theme'=>'user_textfield_render','#size' => '45', '#default_value'=>'jerry jia cecy');
$form['fullname'] = array('#type' => 'textfield','#size' => '32');
$form['month'] = array('#type' => 'select','#options' => $period);
$form['day'] = array('#type' => 'select','#options' => $period);
$form['year'] = array('#type' => 'select','#options' => $period);

$form['submit'] = array('#type' => 'submit', '#value' => t('Save form'));

$form['#theme'] = 'simplygreen_register_user_form';
$form['#submit'] = array('register_user_form_submit');

return $form;
}

然后在该模块的hook_theme中加入代码注册该模板:

/**
* Implementation of hook_theme().
*/
function user_theme() {
return array(
'user_picture' => array(
'arguments' => array('account' => NULL),
'template' => 'user-picture',
),
'simplygreen_register_user_form' => array(
'arguments' => array('form' => NULL),
'template' => 'theme_register_user_form',
),
'user_textfield_render' => array(
'arguments' => array('textfield' => NULL),
'template' => 'theme_user_custom_textfield',
),
);
}