System settings form():修订间差异
来自站长百科
(新页面: <span style="border:1px solid #000; text-align:center; float:right; padding:6px; margin-bottom:15px;"><strong>导航:</strong> 上一页 | {{Template:Drupal导航}}</span> <div...) |
无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第3行: | 第3行: | ||
'''system_settings_form($form)''' --很重要的一个函数,在设置后台表单时候经常用到。主要用于为一个表单添加按钮和设置前缀. | |||
'''参数''': | |||
$form 一个包含表单结构的关联数组。 | |||
'''返回值''': | |||
表单结构。 | |||
'''实例''': | |||
<pre> | |||
<?php | |||
function onthisdate_admin() { | |||
$form = array(); | |||
$form['onthisdate_maxdisp'] = array( | |||
'#type' => 'textfield', | |||
'#title' => t('Maximum number of links'), | |||
'#default_value' => variable_get('onthisdate_maxdisp', 3), | |||
'#size' => 2, | |||
'#maxlength' => 2, | |||
'#description' => t("The maximum number of links to display in the block."), | |||
'#required' => TRUE, | |||
); | |||
return system_settings_form($form); | |||
} | |||
?> | |||
</pre> | |||
'''详解''':对于实际元素设置,我们只要定义表单元素即可。-----system_settings_form()函数将处理创建表单页面,添加提交按钮和保存设置。 | |||
[[category:API|D]] | [[category:API|D]] | ||
[[category:Drupal|D]] | [[category:Drupal|D]] |
2010年7月11日 (日) 17:15的最新版本
导航: 上一页 | 首页 | DedeCMS | 帝国CMS | Xoops | SupeSite | PHPCMS | PHP168 | Joomla
system_settings_form($form) --很重要的一个函数,在设置后台表单时候经常用到。主要用于为一个表单添加按钮和设置前缀.
参数:
$form 一个包含表单结构的关联数组。
返回值:
表单结构。
实例:
<?php function onthisdate_admin() { $form = array(); $form['onthisdate_maxdisp'] = array( '#type' => 'textfield', '#title' => t('Maximum number of links'), '#default_value' => variable_get('onthisdate_maxdisp', 3), '#size' => 2, '#maxlength' => 2, '#description' => t("The maximum number of links to display in the block."), '#required' => TRUE, ); return system_settings_form($form); } ?>
详解:对于实际元素设置,我们只要定义表单元素即可。-----system_settings_form()函数将处理创建表单页面,添加提交按钮和保存设置。