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

推荐订阅源

N
Netflix TechBlog - Medium
IT之家
IT之家
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
小众软件
小众软件
博客园 - 叶小钗
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理

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