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

推荐订阅源

N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Docker
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Scott Helme
Scott Helme
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security

博客园 - 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',
),
);
}