typoscript::formhandler::dropdown::static_countries

Formhandler doc proposes the following:
options_dropdown = CONTENT
options_dropdown{
table = tx_addresses_domain_model_address
select {
pidInList = 1
orderBy = last_name
selectFields = uid, first_name, last_name
# possible conditions
# where = ( tx_mytable.type='b0' OR tx_mytablet.type='b1' )
}
renderObj = COA
renderObj {
#value
10.wrap =13.field = first_name
}
}

This, however doesn’t work at all. The field uid is not used twice for 10 = TEXT and 12=TEXT but alternatively. The “checked” functionality doesn’t work either.

the following works:

plugin.Tx_Formhandler.settings.predef.myForm.markers.dropdown_countries = CONTENT
plugin.Tx_Formhandler.settings.predef.myForm.markers.dropdown_countries {
table=static_countries
select.pidInList = 0
select.selectFields=uid,cn_official_name_en

Since v4.3 TYPO3 it is posible to use static_* databases in CONTENT cobj. The PID (= Page ID) of the entries of static_countries is 0 because tables of the extension static_info_tables are all saved on the very root page of every typo3 installation.
select.selectFields=uid,cn_official_name_en
Select the fields of static_countries (look it up with phpmyadmin if you like) you want to use later in the dropdown menu

define render Object (renderObj)

...snip...
renderObj=COA
renderObj{
10=TEXT
10.dataWrap=20.field=cn_official_name_en
}
}

But why define a COA with different text parts? with dataWrap one can comfortably replace whatever {field:…} you define:

renderObj=TEXT
renderObj.dataWrap=

That’s it! Now just define the marker you used to define this typoscript in your template.html:
In my case it is dropdown_countries from
plugin.Tx_Formhandler.settings.predef.myForm.markers.dropdown_countries = CONTENT

this should look like this:



###LLL:selectValue###
###dropdown_countries###


###dropdown_countries### gets replaced by the option tags we defined in typoscript and the ###selected_country_dropdown_{field:uid}### marker gets replaced by formhandler (if the entry was selected, otherwhise it gets deleted by formhandler) into checked=”checked”.

The checked marker has to be of ###checked_[fieldname]_[fieldvalue]###, where fieldname is the name of the field (without formhandler[]) and fieldvalue is the value of the field (in our case it is the uid-value that gets replaced by the typoscript {field:uid}