2017-03-29 43 views
0

大家好我被困在一個地方,我創建了一個自定義字段類型和字段控件,並且在我的字段控件中我必須調用js作爲圖像選擇按鈕被選中。這裏是我的自定義字段部件代碼在自定義字段控件中的formElement中附加庫

public function formElement(
FieldItemListInterface $items, 
$delta, 
Array $element, 
Array &$form, 
FormStateInterface $formState 
) { 
$s3FormDetailss = GetSignature::getSignature();// To get the policy 

$element['s3_select_image'] = array(
'#type' => 'managed_file', 
'#title' => t($element['#title']), 
'#description' => t('Upload to s3'), 
'#default_value' => isset($items[$delta]->s3_upload_bucket_name) ? 
    $items[$delta]->s3_upload_bucket_name: null, 
$form['#attached']['#library'][]= 's3_file_uploader/s3_file_uploader-s3_file_uploader-styles', 
$form['#attached']['drupalSettings']['s3_file_uploader']['s3_file_uploader-s3_file_uploader-styles']['variable'] = $s3FormDetailss, 

); 

我想在這裏附上庫,但我得到的錯誤 「你不允許在#attached使用#library。」

回答

2

嘗試刪除#號: $form['#attached']['library'][]= '';

相關問題