Search code examples
ajaxformstypo3typo3-extensions

How to get a typo3 form-framework form html via ajax


I've got an experimental project at work where I have to check whether or not it is practical to use Typo3 in a headless way, with most of the Typo3 stuff still working.

For the Rest Api I'm using tx_rest to expose my endpoints.

In particular I'm currently trying to get the rendered html of a form, which was created by a backend user, with the Typo3 form framework, via ajax.

Does anyone know of a way to retrieve only the rendered html form from Typo3?


Solution

  • Does anyone know of a way to retrieve only the rendered html form from TYPO3?

    Create a new PAGE object with a custom number

    formPage = PAGE
    formPage.typeNum = 765
    

    and set

    formPage.config {
        debug = 0
        disableAllHeaderCode = 1
        disablePrefixComment = 1
        xhtml_cleaning = none
        admPanel = 0
    }
    

    to prevent any other output and finally

    formPage.10 < styles.content.get
    

    (or use any other setup to fetch your content, this is just an example, that will output all contents of the current page in colPos 0)

    Opening your page with https://myhost.com/my/path/?type=765 will then render anything on the page without any additional markup, just the output of your page content (e.g. the form plugin, etc.).