I am currently working on a plugin for Ilias and I want to have a table in a modal, with a radio button for each column, and after pushing a "save"-Button, I want to have the id of the selected column posted for my saving function.
The problem I am dealing with is, that the save button has to be in the modal footer (convention of the roundtrip modal, and in fact much more beautiful than having a command button), so I cannot use the addCommandButton functionality for the table.
I am having code like this in my main GUI class:
$modal = $factory->modal()
->roundtrip("title"), $this->getModalContent()
->withActionButtons([
$factory->button()->standard("save", $this->ctrl->getLinkTargetByClass(myGUIClass::class, "save"))
]);
$modalbutton = $factory->button()->standard("open modal", "")->withOnClick($modal->getShowSignal());
$mytemplate->setVariable("SOMEVARIABLE", $renderer->render([$modalbutton, $modal]));
And the getModalContent function does some things and then asks for the table html:
$tab = new ilMyGUIClassModalTableGUI($this, "parentCmd");
$html = $tab->getHTML();
$modalContent = $factory->legacy($html);
return $modalContent;
The table GUI class looks like this:
function __construct($a_parent_obj, $a_parent_cmd)
{
global $DIC;
$this->ctrl = $DIC->ctrl();
$this->lng = $DIC->language();
$this->access = $DIC->access();
$this->user = $DIC->user();
$ilUser = $DIC->user();
$this->parent_obj = $a_parent_obj;
$this->cur_id = //an_arbitrary_old_id;
parent::__construct($a_parent_obj, $a_parent_cmd);
$this->setData($this->getData());
$this->setTitle("some title");
$this->setLimit(9999);
$this->addColumn("", "", "", true);
$this->addColumn("column1");
$this->addColumn("column2");
$this->setEnableHeader(true);
$this->setRowTemplate("tpl.template.html", "tplPath");
$this->disable("footer");
$this->setEnableTitle(true);
$this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
}
function getData()
{
return //an array with id, value_column_1, value_column_2;
}
protected function fillRow($a_set)
{
if ($this->cur_id == $a_set["id"])
{
$this->tpl->setVariable("CHECKED", "checked='checked'");
}
$this->tpl->setVariable("ID", $a_set["id"]);
$this->tpl->setVariable("COLUMN1", $a_set["column1"]);
$this->tpl->setVariable("COLUMN2", $a_set["column2"]);
$this->ctrl->setParameter($this->parent_obj, "my_postvar", $a_set["id"]);
}
When I now click on the save-button, it only gets the last parameter that was set, and not the one of the column I selected in the $_GET variable.
Is there any possibility to have the selected column in a post variable or, if not, how to correctly set the get variable for my main gui class?
Thanks a lot!