表格操作在树枝模板

时间:2017-03-30 09:23:23

标签: php jquery twig drupal-8 custom-field-type

嗨我在树枝模板中遇到问题。我正在尝试的是使用自定义模块和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;
 }

这是twig class

{{ 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>

在twig类中,一切都正常,但是表单标签内的所有内容都不起作用,不知道为什么请帮助

0 个答案:

没有答案
相关问题