17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1915 Views |
-
DataObject defaults and CheckBoxField Questions

23 April 2008 at 9:35am
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 inss 2.2.1
-
Re: DataObject defaults and CheckBoxField Questions

23 April 2008 at 10:02am
mea culpa...
instead of
$fields->push( new CheckBoxField('MyOption','MyOption','1'));
i had
$fields->push( new CheckBoxField('MyOption','MyOption'),'1');ARRGH.
time to go to bed now.....
| 1915 Views | ||
|
Page:
1
|
Go to Top |

