You are here

38 text_format(文本格式)

admin 的头像
Submitted by admin on 星期二, 2015-06-23 09:49

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

    文本域启用了文本格式的版本。它还包含两个非标准属性:

· #format: 要应用的格式。如果你想使用默认格式,那么可将这个属性设置为NULL,剩下的工作便会交给过滤器系统。

· #base_type (optional): 默认为'textarea'。也可以将文本格式选择器附加在其它表单元素类型上,比如文本字段。

 

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

 

$form['signature_settings']['signature'] = array(

'#type' => 'text_format',

'#title' => t('Signature'),

'#default_value' => isset($account->signature) ? $account->signature : '',

'#description' => t('Your signature will be publicly displayed at the end of your comments.'),

'#format' => isset($account->signature_format) ? $account->signature_format : NULL,

);

 

常用属性: #access、 #after_build、 #ajax、 #attributes、 #cols (默认为 60)、 #default_value、 #description、 #disabled、 #element_validate、 #parents、 #post_render、 #prefix、 #pre_render、 #process、 #required、 #resizable (默认为 TRUE)、 #rows (默认为 5)、 #states、 #suffix、 #theme、 #theme_wrappers、 #title、 #title_display、 #tree、#type、 #weight


Drupal版本: