[TYPO3] Formfields from database (feeding a valueArray from theDatabase)
Peter Klein
peter at umloud.dk
Thu Jul 12 10:10:16 CEST 2007
Hi Frank.
It can be done, but you need a different approch, as the "valueArray"
doesn't have stdWrap support. Only the "label" and "value" properties inside
the valueArray has stdWrap support. (But they can't be used for this
purpose, as you need a seperate set of label/value to generate each OPTION
tag in your SELECT.
Instead you could use the "data" property, and then generate the correct
format using TS.
So what we need to generate, is a string similar to this:
Haircolor: | haircolor=select| Blue=blue , Red=red , Brown=brown
Here's an example:
-- cut --
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 {
table = tx_mytable
select.pidInList = 54
# Here each Label/Value for the option tage is generated, seperated
with a comma
renderObj = TEXT
renderObj.dataWrap = {field:title}={field:uid},
# Finally we removed the last comma from the string.
stdWrap.substring = 0,-1
}
}
}
-- cut --
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.
--
Peter Klein/Umloud Untd
"Frank Berger" <foppel at gmail.com> skrev i en meddelelse
news:mailman.7261.1184222163.29892.typo3-english at lists.netfielders.de...
> Hi Folks,
> I don't know if that can be done at all, or if there is a better way to do
> that.. essentialy this is what i am trying (which doesn't work at all):
>
> the mailform is just an example, I could imagine other forms as well where
> i
> would want that..
>
> tt_content.mailform.20 {
>
> dataArray {
>
>
> 40.label = Kategorien:
>
> 40.type = category=select
>
>
> 40.valueArray {
>
> 10.label=Please select
>
> 10.value =
>
> table = my_categories
>
> select {
>
> orderby = category
>
> selectFields = uid,category
>
> }
>
> }
>
> }
>
> }
>
>
> I want do feed the data for a valueArray from a certain table (which is
> properly configured in $TCA). Additionaly i would like to add a field
> which
> is not in the database at all (please select)
>
>
> I am sorry, but I frankly don't have any clue what i should or could do at
> this point. Google was fruitless for me, as i didn't find a similar
> question
> or solution or idea for a solution.
>
>
> thanks in advance for any hint
>
> Frank
More information about the TYPO3-english
mailing list