/**
  * Test NullableField::setValue works when passed an array values,
  * which happens when the form submits.
  */
 public function testSetValueArray()
 {
     $a = new NullableField(new TextField("Field1", "Field 1"));
     $a->setValue("abc", array("Field1_IsNull" => false));
     $this->assertSame("abc", $a->dataValue());
     $a = new NullableField(new TextField("Field1", "Field 1"));
     $a->setValue("", array("Field1_IsNull" => false));
     $this->assertSame("", $a->dataValue());
     $a = new NullableField(new TextField("Field1", "Field 1"));
     $a->setValue("", array("Field1_IsNull" => true));
     $this->assertSame(null, $a->dataValue());
 }
 private function Fields()
 {
     return FieldList::create(TextField::create('Title'), TextField::create('Subtitle'), CheckboxField::create("IsTrue"), CheckboxSetField::create('CheckboxSet', 'Options', array('Opt1' => 'Opt1', 'Opt2' => 'Opt2', 'Opt3' => 'Opt3', 'Opt4' => 'Opt4', 'Opt5' => 'Opt5')), DropdownField::create('DDP', 'Choose an item', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'))->setEmptyString('(Select one)'), GroupedDropdownField::create('DDP2', 'Choose an item', array('Group1' => array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'Group2' => array('ITEM6' => 'Item 6', 'ITEM7' => 'Item 7', 'ITEM8' => 'Item 8', 'ITEM9' => 'Item 9', 'ITEM0' => 'Item 0')))->setEmptyString('(Select one)'), ListboxField::create('lbf', 'Choose items', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'ITEM3'), LookupField::create('lf', 'Look up field', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'ITEM3')->setEmptyString('(Select one)'), NullableField::create(TextField::create("nf", "Field 1", "abc")), NullableField::create(CheckBoxField::create("nf2", "Field 1", "abc")), NumericField::create("nf3", "NumericField", 10), NumericField_Readonly::create('NFR1', 'NumericField_Readonly'), OptionsetField::create($name = "op", $title = "OptionsetField", $source = array("1" => "Option 1", "2" => "Option 2", "3" => "Option 3", "4" => "Option 4", "5" => "Option 5"), $value = "3"), ReadonlyField::create('rf1', 'read only field', 'value'), TextareaField::create($name = "description", $title = "Description", $value = "This is the default description"), DateField::create('datefield', 'Date Field')->setConfig('showcalendar', true), TimeField::create('timeField', 'Time Field', '12am'));
 }