Can anyone please help? I created a CheckboxSetField following the documentation, but I couldn't figure out in neither the forum or documentation how to display the result:
$Topics returns 1, 2 (etc)
<% control Topics %>
$Topics
<% end_if %>
returns a blank
and
<% control Topics %>
<ul>
<% if 1 %><li>Technology</li><% end_if %>
<% if 2 %><li>Gardening</li><% end_if %>
<% if 3 %><li>Cooking</li><% end_if %>
<% if 4 %><li>Sports</li><% end_if %>
</ul>
<% end_control %>
Returns
- Technology
- Gardening
- Cooking
- Sports
whatever is checked.
Do I need to write a controller?
Here the code that I used:
static $db = array(
'Topics' => 'Varchar',
);
and
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldsToTab(
'Root.Content.Main',
array(
new CheckboxSetField(
$name = "Topics",
$title = "I am interested in the following topics",
$source = array(
"1" => "Technology",
"2" => "Gardening",
"3" => "Cooking",
"4" => "Sports"
),
$value = "1"
)
)
);
return $fields;
}
}