【发布时间】:2014-03-27 06:20:10
【问题描述】:
我需要在我的 Drupal 表单中为所有语言创建下拉列表,PHP 中是否有任何函数可以实现这一点。我想创建一个包含所有语言的数组并将其传递给 drupal 形式。
function video_upload_subtitles_form($form, &$form_state) {
$form = array('#attributes' => array('enctype' => 'multipart/form-data'));
$lang_list = array();//**how to create this array**
$form['video_name'] = array(
'#title' => t('Name Of the video'),
'#type' => 'textfield',
);
$form['sub_file'] = array(
'#type' => 'file',
'#title' => t('Upload video'),
'#description' => t('Pick a video file to upload.'),
);
$form['user_list']=array(
'#type'=>'select',
'#title' => t('Language'),
'#options' => $lang_list,//array of language
'#multiple' => false,
'#attributes'=>array('size'=>4),
'#weight'=>8,
);
$form['submit_button'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
我知道语言列表可以在 php 中通过手动列出和创建数组来完成,但是否可以使用任何 php 函数,只是寻找一些简单的方法来节省时间。
为Country List 找到了这个很酷的网站。有这样的语言吗
【问题讨论】:
-
尝试更改,我希望这很有用
-
@Mehul:谢谢!!!我会试试这个新代码:)
标签: php arrays drupal drupal-7 lang