formstypo3typo3-12.x

TYPO3 EXT:form prefill a form field with an id of the current object defined in the object table (not uid)


I have a small form in TYPO3 V12 that generates a request for more information on the current object, I'd like to prefill a form field with the id of the object so that it is send with the request, I could not find how to do this.

update: the code of thomas (with a small correction) works but it gives a url parameter (the uid of the object), I need to get a defined object_id from the tx_myext_object_table


Solution

  • With help of my friend Paul Beck I Figured out how to do a proper database search with typoscript, this script produces the result I was looking for:

    
    plugin.tx_form {
        settings {
            formDefinitionOverrides {
                <formName> {
                    renderables {
                        <indexOfPage> {
                            renderables {
                                <indexOfRenderable> {
                                    defaultValue = CONTENT
                                    defaultValue {
                                        table = tx_myext_domain_model_object
                                        select {
                                            pidInList = <objectStoragePid>
                                            uidInList = TEXT
                                            uidInList.data = GP:<urlParam>
                                        }
                                        renderObj = TEXT
                                        renderObj.field = object_id
                                        intval = 1
                                        wrap = #|
                                        if {
                                            isTrue = 1
                                            isTrue.data = GP:<urlParam>
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }