Hi, I'm planning to build an eCard Module. Therefore I need a Form with Radiobuttons in the Frontend like it's used in the Poll Tutorial (Tut 3). But instead of simple Text next to the single Radiobuttons I want a small preview of the Cards to select one. How is it possible to fill an OptionsetField with more than just Text? Is it possible to fill the Array with ImageObjects?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Is this impossible with the given Objects or does noone have an Idea?
Is your problem solved? Did you make the eCard Module?
I'm looking for an e-card module for SS.
Well... I have just made a really nice HACK for this, but I also have an idea how to make this nicely...
sapphire\forms\OptionsetField.php
function Field() {
...
if ($this->name == 'NAMEOFFORMFIELD') {
$options .= "<li class=\"".$extraClass."\">"
."<input id=\"$itemID\" name=\"$this->name\" type=\"radio\" value=\"$key\"$checked $disabled class=\"radio\" />"
//image added here...
."<img src=\"cms/images/check.png\" />"
."<label for=\"$itemID\">$value"
."</label>"
."</li>\n";
}
else {
$options .= "<li class=\"".$extraClass."\"><input id=\"$itemID\" name=\"$this->name\" type=\"radio\" value=\"$key\"$checked $disabled class=\"radio\" /> <label for=\"$itemID\">$value</label></li>\n";
}
...
}
so that is the hack, so the nice way to do this is to create an ImageOptionsetField, that inherits from OptionsetField and then allows setting of an array to handle the images. For the project this is in - I'm going to recommend this, but since I'm not coding it myself, I haven't added it here...
enjoy! :)