Question: Is it possible to feed a TYPO3 TS form with data from a database table, in order to generate a SELECT/OPTION tagset?

Submitting your vote...
Rating: 4.5 of 5. 4 vote(s).
Click the rating bar to rate this item.

Answer: Yes. It's possible by using the "data" property of the FORM object, and then generate the correct

format using TS.

 

The only (minor) drawback, is that form created using "dataArray", will always be added AFTER the fields you create using the "data" property.

So it's best to create the entire form using the "data" property.

 

So what we need to generate, is a string similar to this:

 

Haircolor: | haircolor=select| Blue=blue , Red=red , Brown=brown

 

#[Standard FORM object stuff here..]
data.cObject = COA
data.cObject {
  	# First we generate the static part of the string.
  10 = TEXT
  10.value = Haircolor: | haircolor=select |
   
  	# Then we collect the data from DB
  20 = CONTENT
  20 {
    		# This is the table we want to get data from.
    table = tx_mytable
    select.pidInList = 54
     
    		# Here each Label/Value pair for the option tag is generated,
    		# with each pair seperated by a comma
    renderObj = TEXT
    renderObj.dataWrap = {field:title}={field:uid},
     
    		# Finally we removed the last comma from the string.
    stdWrap.substring = 0,-1
  }
}
#[Standard FORM object stuff here..]

 

 

This snippet was submitted by Peter Klein



Comments


No comments

Add comment

* - required field

*



*
*

Top 10 Updates

Nice fonts using Google font API geändert am  20-May-2010 16:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 18:27:15
TYPO3 SEO geändert am  30-Apr-2010 09:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 09:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 12:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 12:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 12:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 14:02:48
Sample DHTML menu geändert am  01-Feb-2009 13:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 13:20:39

Latest comments

21-Jan-2012 20:22:24
jemmkwc jemmkwc schrieb: MOGWOX , [url=http://prdpuhwzxyrc.com/]prdpuhwzxyrc[/url],...
fe_useradmin form does not save
20-Jan-2012 20:35:32
fsivjktiuld fsivjktiuld schrieb: idCmnv <a href="http://gakbrrkrxhye.com/">gakbrrkrxhye</a>
fe_useradmin form does not save
19-Jan-2012 18:05:25
bvffee bvffee schrieb: jl2vQt , [url=http://xcinvpbclrbm.com/]xcinvpbclrbm[/url],...
External links and shortcuts directly in the menu
Deutsch
Search: