Account created on 29 January 2024, about 1 year ago
#

Recent comments

I have tried all the above method still not working 
I have form as below
 

    $form['post_message'] = [
      '#type' => 'textarea',
      '#placeholder' => t('What\'s on your mind today'),
      '#attributes' => ['id' => ['myPostMessage']],
      '#required' => TRUE,
      '#maxlength' => 200,
      '#attached' => [
        'library' => [
          'post_social/post_social'
        ],
      ], // Change 100 to your desired word limit.
    ];



    $form['files'] = [
      '#type' => 'managed_file',
      '#title' => $this->t('Upload Files'),
      '#description' => $this->t('Upload multiple files, including images and documents.'),
      '#attributes' => [
        'id' => 'edit-file-upload',
      ],
      '#prefix' => '<div id="file-upload-wrapper">',
      '#suffix' => '</div>',
      '#multiple' => TRUE,
      '#upload_validators' => [
        'file_validate_extensions' => ['png gif jpg jpeg svg mp3 wav aac txt rtf doc docx pdf mp4'],
      ],
      '#upload_location' => 'public://',
    ];


    $form['submit'] = array(
      '#type' => 'submit',
      '#ajax' => array(
        'callback' => '::submitFormAjax',
      ),
      '#value' => t('Post'),
      '#id' => 'submit_post',
    );

    $form['message_container'] = [
      '#type' => 'markup',
      '#markup' => '<div class="post-social-form-message"></div>',
    ];

    $form['#attached']['library'][] = 'core/jquery';
    $form['#attached']['library'][] = 'post_social/post_social';

Have the call back function as below
 

  public function submitFormAjax(array &$form, FormStateInterface $form_state) {


    $response = new AjaxResponse();



    return $response;
  }

 

How to remove the uploaded file after form submission

Production build 0.71.5 2024