TYPO3-Headless / headless_powermail

Connects together EXT:headless and EXT:powermail
GNU General Public License v2.0
0 stars 6 forks source link

Submit Page Link not outputted in JSON #8

Open MartinsOsawe opened 2 years ago

MartinsOsawe commented 2 years ago

Hello thanks for this awesome extension :)

When i set a redirection page link for the submit page, i don't get any information about this in the JSON. Is it possible to set this?

Thank you for your help

Bildschirmfoto 2021-11-15 um 13 15 16

ducrot commented 2 years ago

Hello!

One possible solution:

Backend TypoScript setup:

plugin.tx_powermail {
    settings {
        setup {
            misc {
                ## Enable ajaxSubmit to get redirect url via data.form.additionalAttributes.data-powermail-ajax-uri
                ajaxSubmit = 1
            }
            finishers {
                ## Disable RedirectFinisher
                100 >
            }
        }
    }
}

Frontend:

export default {

// [...]

 computed: {
    redirect() {
      return this.data.form.additionalAttributes
      && this.data.form.additionalAttributes['data-powermail-ajax-uri']
        ? this.data.form.additionalAttributes['data-powermail-ajax-uri']
        : false
    }
  },

// [...]

  methods: {
    onSubmit() {
      // Do your validation stuff ...
      apiService.postFormdata(this.action, formData, this.$typo3.options.api.baseURL)
        .then(response => {
          if (this.redirect) {
            this.$router.push({
              path: this.redirect
            })
          } else {
            // Show a message!
          }
        })
        .catch((error) => {
          console.error("Error", error);
        });
    }
  },

// [...]

};
kitzberger commented 8 months ago

@MartinsOsawe, I think this has been resolved with #26, no?