0

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

2
  • Where do you get the object id? Is it in the url parameter? Or can it be set for the complete page via e.g. TypoScript or plugin setting? Commented Aug 15 at 7:41
  • @ThomasLöffler it is a variable in the page, like the id of a news article, and it would be the detail page so it is for the whole page Commented Aug 15 at 16:54

2 Answers 2

1

You can override values in the form via TypoScript.

You need to replace the <> values with your own.
The <indexOfRenderable> you get with the position (beginning with zero) of the field in your form yaml file.

The usage of defaultValue fits for my needs. As I don't have an example with a hidden field, you need to take a look which configuration you need to adjust.
Example (working in v12 with a select field):

plugin.tx_form {
  settings {
    formDefinitionOverrides {
      <formName> {
        renderables {
          <indexOfRenderable> {
            defaultValue = TEXT
            defaultValue.data = GP:<urlParam>
            defaultValue.intval = 1
            defaultValue.if {
              isTrue = 1
              isTrue.data = GP:<urlParam>
            }
          }
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

thank you, I had to add two nodes but this worked, only that I'd need a value from the database to fill the field, not a url parameter ... not that good with typoscript, but that should be doable too at this point
do you have it working like this? I edited your answer to add the 'page renderable' otherwise I guess it does not work, but the edit was not approved ??
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.