嗨,我在树枝模板中遇到问题。我正在尝试使用自定义模块和 jquery 文件上传器将图像上传到 s3 存储桶,因为我已经创建了一个自定义字段类型,但是我卡在了我试图从表单元素页面呈现树枝的地方。Twig 正在渲染,但它的一部分不起作用不知道为什么这是我的字段小部件类
public function formElement(
FieldItemListInterface $items,
$delta,
Array $element,
Array &$form,
FormStateInterface $formState
) {
$s3FormDetailss = GetSignature::getSignature();// To get the policy
$element['s3_select_image'] = array(
'#theme' => 'image_uploade_page',
'#s3FormDetails' => $s3FormDetailss,
$element['#attached']['drupalSettings']['variable'] = $s3FormDetailss,
$element['#attached']['library'][]= 's3_file_uploader/s3_file_uploader-styles',
);
return $element;
}
这是树枝课
{{ attach_library('s3_file_uploader/s3_file_uploader-styles') }}
<div class="container">
<!-- <h1>Direct Upload to data</h1> -->
<!-- This part is not working and everything else is working -->
<form action= "{{ s3FormDetails.url }}"
method="POST"
enctype="multipart/form-data"
class="direct-upload">
{% for key,value in s3FormDetails.inputs %}
<input type="hidden" name="{{ key }}" value="{{ value }}">
{% endfor %}
<!-- Key is the file's name on S3 and will be filled in with JS -->
<input type="hidden" name="key" value="">
<input type="file" name="file" multiple>
<!-- Progress Bars to show upload completion percentage -->
<div class="progress-bar-area"></div>
</form>
<!-- This area will be filled with our results (mainly for debugging) -->
<div>
<!-- <h3>Files</h3> -->
<textarea id="uploaded" name="hide" style="display:none;"></textarea>
</div>
</div>
在树枝类中,一切正常,但表单标签内的一切都不起作用不知道为什么请帮忙