function testSelectOptionsAddRemove() { $table = new TableListField("Tester", "TableListFieldTest_Obj", array("A" => "Col A")); $this->assertNull($table->SelectOptions(), 'Empty by default'); $table->addSelectOptions(array("F" => "FieldF", 'G' => 'FieldG')); $this->assertEquals($table->SelectOptions()->map('Key', 'Value'), array("F" => "FieldF", 'G' => 'FieldG')); $table->removeSelectOptions(array("F")); $this->assertEquals($table->SelectOptions()->map('Key', 'Value'), array("G" => "FieldG")); }
/** * According to {@link TableListField->selectOptions}, each record will check if the options' key on the object is true, * if it is true, add the key as a class to the record * * @return string Value for a 'class' HTML attribute. */ function SelectOptionClasses() { $tagArray = array('markingcheckbox'); $options = $this->parent->SelectOptions(); if ($options && $options->exists()) { foreach ($options as $option) { if ($option->Key !== 'all' && $option->Key !== 'none') { if ($this->{$option->Key}) { $tagArray[] = $option->Key; } } } } return implode(" ", $tagArray); }