1: <?php
2:
3: class QCheckBoxListBase_CodeGenerator extends QListControl_CodeGenerator {
4: public function __construct($strControlClassName = 'QCheckBoxList') {
5: parent::__construct($strControlClassName);
6: }
7:
8: 9: 10: 11: 12: 13: 14: 15:
16: public function ConnectorCreateOptions(QCodeGenBase $objCodeGen, QSqlTable $objTable, $objColumn, $strControlVarName) {
17: $strRet = parent::ConnectorCreateOptions($objCodeGen, $objTable, $objColumn, $strControlVarName);
18:
19: if (!$objColumn instanceof QManyToManyReference) {
20: $objCodeGen->ReportError($objTable->Name . ':' . $objColumn->Name . ' is not compatible with a QCheckBoxList.');
21: }
22:
23: return $strRet;
24: }
25:
26: 27: 28: 29: 30: 31:
32: public function ConnectorUpdate(QCodeGenBase $objCodeGen, QSqlTable $objTable, $objColumn) {
33: $strObjectName = $objCodeGen->ModelVariableName($objTable->Name);
34: $strPropName = $objColumn->ObjectDescription;
35: $strPropNames = $objColumn->ObjectDescriptionPlural;
36: $strControlVarName = $objCodeGen->ModelConnectorVariableName($objColumn);
37:
38: $strRet = <<<TMPL
39: protected function {$strControlVarName}_Update() {
40: if (\$this->{$strControlVarName}) {
41: \$this->{$strObjectName}->UnassociateAll{$strPropNames}();
42: \$this->{$strObjectName}->Associate{$strPropName}(\$this->{$strControlVarName}->SelectedValues);
43: }
44: }
45:
46:
47: TMPL;
48: return $strRet;
49: }
50: }