30 markup(标识文本)

作者:老葛,北京亚艾元软件有限责任公司,http://www.yaiyuan.com

    它用来在表单中引入一段文本或者HTML如果一个元素没有设置属性#type,那么它就默认为标识文本元素。。

 

    注意:如果你把文本输出在一个可伸缩的字段集的内部,那么要使用<div>或者<p>标签对其进行包装,这样当字段集被折叠起来时,你的文本也被折叠在了里面;否则你的文本将显示在字段集的外面。

 

示例代码,来自(user.pages.inc):

 

$form['help'] = array('#markup' => '<p>' . t('This login can be used only once.') . '</p>');

 

常用属性: #access、 #after_build、 #element_validate、 #markup、 #parents、 #post_render、 #prefix、 #pre_render、 #process、 #states、 #suffix、 #theme、 #theme_wrappers、 #tree、 #type、 #weight

 

 

password(密码)

    生成一个单行文本字段,在这里用户的输入不直接显示出来。

 

示例代码,来自(user.module):

 

$form['account']['current_pass'] = array(

'#type' => 'password',

'#title' => t('Current password'),

'#size' => 25,

'#access' => !empty($protected_values),

'#description' => $current_pass_description,

'#weight' => -5,

);

 

常用属性:  #access、 #after_build、 #ajax、 #attributes、 #description、 #disabled、 #element_validate、 #field_prefix、 #field_suffix、 #maxlength (默认为128)、 #parents、 #post_render、 #prefix、 #pre_render、 #process、 #required、 #size (默认为60)、 #states、 #suffix、 #theme、 #theme_wrappers、 #title、 #title_display、 #tree、 #type、 #weight

 

 


Drupal版本: