public function updateAttributes(Attributes $attributes) { parent::updateAttributes($attributes); try { unset($attributes['value']); } catch (OutOfBoundsException $e) { } }
{ return $this->start->format('Y-m-d H:i:s'); } } $interestList = array(new Interest(3, 'Play guitar', 2, new DateTime('1998-10-25 10:00:00')), new Interest(7, 'Calligraphy', 4, new DateTime('2004-05-21 13:00:00')), new Interest(14, 'Karate', 1, new DateTime('1982-04-12 17:45:00')), new Interest(78, 'Calculating PI', 5, new DateTime('1977-02-01 03:14:15'))); /** * @brief ... * @var \FormObject\Form */ $form = Form::create($factory); $interests = SelectManyField::create('interests__items', 'Interests'); $columns = array('getId()' => 'InterestID', 'getName()' => 'Description', 'getCategory()' => 'Category', 'getStart()' => 'Interested since'); $extractor = new Extractor('getId()', 'getName()'); $interests->setSrc($interestList, $extractor); $interests->setClassName('MultiCheckboxField'); $interestsRich = SelectManyField::create('interests__itemsRich', 'Interests detailed'); $interestsRich->setSrc($interestList, $extractor)->setColumns($columns); $form->push(TextField::create('name')->setTitle('Name')->setValue('Billy'), TextField::create('surname')->setTitle('Please enter your surname')->setValue('Owner'), $interests, $interestsRich); $nameValidator = new TextValidator(); $nameValidator->required = FALSE; $nameValidator->minLength = 3; $nameValidator->setMaxLength = 12; $surnameValidator = new RequiredValidator(); $surnameValidator->required = TRUE; $validator = new SimpleValidator($form); $validator->set('name', $nameValidator); $validator->set('surname', $surnameValidator); $form->setValidator($validator); $data = array(); if ($form->wasSubmitted()) { $data = $form->data;
$rememberMyRadio = new BooleanRadioField('rememberMyRadio'); $rememberMyRadio->trueString = 'Remember my Radio'; $rememberMyRadio->falseString = 'Forget my Radio'; $rememberMyRadio->setValue(TRUE); $container = new FieldList('group1', 'Tab One'); $container->setSwitchable(TRUE); $form->push($container); $container->push($name)->push($surname)->push($rememberMe)->push($rememberMyRadio); $category = new SelectOneField('category', 'User Category'); $categories = array(1 => 'Customer', 2 => 'Co-Worker', 3 => 'Family', 4 => 'Organisation', 5 => 'Prospect'); $tags = array(1 => 'New', 2 => 'Partner', 3 => 'Important', 4 => 'Reused'); $category->setSrc($categories)->setValue(2); $tagsField = SelectManyField::create('tags')->setTitle('Tags')->setSrc($tags); $category2 = SelectOneField::create('category2', 'User Category 2'); $category2->setSrc($categories)->setClassName('RadioButtonsField'); $tags2 = SelectManyField::create('tags2')->setTitle('Tags 2')->setSrc($tags); $tags2->setClassName('MultiCheckboxField'); $container2 = new FieldList('group2', 'Tab Two'); $container2->setSwitchable(TRUE); $container2->push($category)->push($tagsField)->push($category2)->push($tags2); $form->push($container2); $form->actions->push(Action::create('delete')->setTitle('Delete')); $form('surname')->setValue('Button'); $nameValidator = new TextValidator(); $nameValidator->required = FALSE; $nameValidator->minLength = 3; $nameValidator->setMaxLength = 12; $requiredValidator = new RequiredValidator(); $requiredValidator->required = TRUE; $trueValidator = new BooleanValidator(); $trueValidator->mustBeTrue = TRUE;