5093 Posts in 1516 Topics by 1113 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 436 Views |
-
ListboxField

1 September 2011 at 2:24am
Hi!
I define ListboxField as multiple field . My problem is to show value selected. I define an array ($source) to show list of element in ListboxField, and an array ($value) to show selected value after save. What is wrong?This is my code:
$fields->addFieldToTab("Root.Content.Main", new ListboxField('collezioni','Collezioni',$source, $value, $size=5, $multiple=true,$form=null),'Content');$value = array(
'a' => 'A',
'd' => 'D',
);
$source = array(
'a' => 'A',
'b' => 'B',
'c' => 'C',
'd' => 'D',
); -
Re: ListboxField

2 September 2011 at 7:40pm Last edited: 2 September 2011 7:41pm
There's two things. The first is that the value attribute just wants an array of values, not a value=>name map, so:
$value = array(
'a',
'd',
);
is correct.The second is that the values for forms in the CMS are loaded from the Page object you're editing. So the value stored in collezioni in the database is what will be displayed as selected. You'll need to define collezioni as a database field type that can store multiple values. Some of them are MultiEnum, Varchar and Text.
| 436 Views | ||
|
Page:
1
|
Go to Top |

