TCheckBoxList displays a list of checkboxes on a Web page.
The layout of the checkbox list is specified via {@link setRepeatLayout RepeatLayout},
which can be either 'Table' (default) or 'Flow'.
A table layout uses HTML table cells to organize the checkboxes while
a flow layout uses line breaks to organize the checkboxes.
When the layout is using 'Table', {@link setCellPadding CellPadding} and
{@link setCellSpacing CellSpacing} can be used to adjust the cellpadding and
cellpadding of the table.
The number of columns used to display the checkboxes is specified via
{@link setRepeatColumns RepeatColumns} property, while the {@link setRepeatDirection RepeatDirection}
governs the order of the items being rendered.
The alignment of the text besides each checkbox can be specified via {@link setTextAlign TextAlign}.
protected function createSetControl($container, $column, $record) { $value = $this->getRecordPropertyValue($column, $record); $selectedValues = preg_split('/\\s*,\\s*/', $value); $control = new TCheckBoxList(); $values = $column->getDbTypeValues(); $control->setDataSource($values); $control->dataBind(); $control->setSelectedIndices($this->getMatchingIndices($values, $selectedValues)); $control->setID(self::DEFAULT_ID); $control->setCssClass('set-checkboxes'); $this->setNotNullProperty($container, $control, $column, $record); return $control; }
/** * Ensure that the ID attribute is rendered and registers the javascript code * for initializing the active control. */ protected function addAttributesToRender($writer) { parent::addAttributesToRender($writer); if ($this->getEnableClientScript() && $this->getAutoPostBack() && $this->getPage()->getClientSupportsJavaScript()) { $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getPostBackOptions()); } }