[TYPO3-english] mm_forum - extending user profile with select box
Peter Klein
peter at umloud.dk
Thu Aug 20 09:33:20 CEST 2009
Hi Sean.
I did it like this:
-- cut --
label = TEXT
label {
value = Kommune / Organisation
}
input = COA
input {
// Save current value in register
5 = LOAD_REGISTER
5.fieldvalue.field = fieldvalue
wrap = <select
name="###USERFIELD_NAME###">|</optgroup></select>
10 = CONTENT
10 {
table = tx_sbnregional_municipal
select {
pidInList = 1351
where = 1=1
orderBy = region,title
}
renderObj = COA
renderObj {
10 = CONTENT
10 {
table = tx_sbnregional_region
select {
pidInList = 1351
andWhere.dataWrap =
uid={field:region}
}
renderObj = TEXT
renderObj {
value = <optgroup
label="{field:title}">
insertData = 1
override =
</optgroup><optgroup label="{field:title}">
override.if.isTrue.data =
register:region
}
stdWrap.if {
value.field = region
equals.data = register:region
negate = 1
}
}
20 = COA
20 {
10 = TEXT
10.dataWrap = <option
value="{field:uid}" label="{field:title}"
selected="selected">{field:title}</option>
10.if.value.data = register:fieldvalue
10.if.equals.field = uid
20 < .10
20.dataWrap = <option
value="{field:uid}" label="{field:title}">{field:title}</option>
20.if.negate = 1
}
30 = LOAD_REGISTER
30.region.field = region
}
}
}
output = COA
output {
10 = CONTENT
10 {
table = tx_sbnregional_municipal
select {
pidInList = 1351
andWhere.dataWrap = uid={field:fieldvalue}
orderBy = title
}
renderObj = TEXT
renderObj.field = title
}
}
datasource = tx_sbnregional_kom_org
-- cut --
It's a bit more advanced than your snippet, as it fills the selectbox
with data from 2 DB tables (OPTGROUP data comes from table1, and
OPTION data from table2)
The current selected item is stored in the LOAD_REGISTER part, and
then reused in various places of the script.
--
Peter Klein
On Wed, 19 Aug 2009 23:51:27 -0700 (PDT), seanbro
<sean.brokenshire at sydney.msf.org> wrote:
>
>I have updated my code with some minor changes to make it update the database
>properly. Just the name attribute. I still have the problem of finding a way
>to insert the "selected='selected'" attribute on the saved option.
>
>Hope you can help me out.
>
>Sean.
>
>-------
>
>label = TEXT
>label {
> value = Medical or Non-Medical
>}
>input = COA
>input {
> 20 = TEXT
> 20.value = <select name="tx_mmforum_pi5[userfield][10]"
>size="1"><option>Medical</option><option>Non-Medical</option></select>
>}
>datasource = a_medical_nonmedical
>
>-------
More information about the TYPO3-english
mailing list