I'm experiencing some troubles in defining a form for my from DataObject derived Class.
class MyClass1 extends DataObject {
...
static $defaults = array (
"MyTextField" == "MyValue"
"MyOption" => true
..
}
static $db = array(
"MyTextField" => "Varchar"
,"MyOption" => "Boolean"
)
i'm using this class within a
ManyManyComplexTableField relation of MyClass2
where i reference
$complex_field2 = new ManyManyComplexTableField(
$this ,'Class1List' ,'MyClass1 ' ,array('Name' => 'Name')
,'getCMSFields_forPopup'
);
$complex_field2->setParentClass('MyClass2');
First Try:
MyClass1
function getCMSFields_forPopup() {
$fields->push( new TextField('MyTextField','MyTextField'));
$fields->push( new CheckBoxField('MyOption','MyOption'));
...
}
Didn't show any Default Values on the form, as i expected.
So i think these 'Default values' will only be 'hot' when i create a new instance by code.
am i right here?
The behaviour on Page derived things is different there i think.
So i tryed:
function getCMSFields_forPopup() {
$fields->push( new TextField('MyTextField','MyTextField',self::$defaults['MyTextField']));
$fields->push( new CheckBoxField('MyOption','MyOption',self::$defaults['MyOption']));
...
}
which works fine for the Text Field. Now the Default Value is shown
but didn't help for the CheckBox.
Neither
$fields->push( new CheckBoxField('MyOption','MyOption',true));
Nor
$fields->push( new CheckBoxField('MyOption','MyOption',1));
nor
$fields->push( new CheckBoxField('MyOption','MyOption','1'));
does help.
the option is never preselected waht i wanted to be.
so i'm totally confused.
can anyone explain me what i'm doing wrong?
is there a bug in
ss 2.2.1