コード例 #1
0
}
$interestList = array(array('id' => 3, 'name' => 'Play guitar', 'categoryId' => 2, 'start' => new DT('1998-10-25 10:00:00')), array('id' => 7, 'name' => 'Calligraphy', 'categoryId' => 4, 'start' => new DT('2004-05-21 13:00:00')), array('id' => 14, 'name' => 'Karate', 'categoryId' => 1, 'start' => new DT('1982-04-12 17:45:00')), array('id' => 78, 'name' => 'Calculating PI', 'categoryId' => 5, 'start' => new DT('1977-02-01 03:14:15')));
$columns = array('id' => 'InterestID', 'name' => 'Description', 'categoryId' => 'Category', 'start' => 'Interested since');
$itemForm = Form::create($factory);
$itemForm->push(HiddenField::create('id', 'ID'), TextField::create('name', 'Description'), SelectOneField::create('categoryId', 'Category')->setSrc($categories), TextField::create('start', 'Interested since'));
/**
 * @brief ...
 * @var \FormObject\Form
 */
$form = Form::create($factory);
$form->push($interests = EditManyField::create('items', 'Interests')->setValue($interestList)->setItemForm($itemForm));
$interests->addCssClass('draggable')->addCssClass('removable')->addCssClass('addable');
$nameValidator = new TextValidator();
$nameValidator->required = TRUE;
$nameValidator->minLength = 3;
$nameValidator->setMaxLength = 12;
$surnameValidator = new RequiredValidator();
$surnameValidator->required = TRUE;
$requiredValidator = new BooleanValidator();
$requiredValidator->mustBeTrue = TRUE;
$validator = new SimpleValidator($form);
$validator->set('name', $nameValidator);
// $validator->set('surname', $surnameValidator);
// $validator->set('rememberMyRadio', $requiredValidator);
// $validator->set('message', $requiredValidator);
$itemForm->setValidator($validator);
$data = array();
if ($form->wasSubmitted()) {
    $data = $form->getData();
}
include dirname(__FILE__) . '/themes/bootstrap/templates/index.phtml';
コード例 #2
0
        return 'Business';
    }
    return 'Personal';
});
$grouper2 = new OptionGrouper(function ($grouper, $item) {
    if (in_array("{$item}", array('Customer', 'Organisation', 'Organisation'))) {
        return 'Business';
    }
    return 'Personal';
});
$grouper2->setTitle('Business', 'Work')->setTitle('Personal', 'Home');
$form->push(TextField::create('name')->setTitle('Please enter your name')->setValue('Billy'), TextField::create('surname')->setTitle('Please enter your surname')->setValue('Talent'), CheckboxField::create('rememberMe')->setTitle('Remember Me'), BooleanRadioField::create('rememberMyRadio')->setTitle('Remember my radio')->setStringForTrue('Remember my radio')->setStringForFalse('Forget my radio')->setValue(TRUE), TextField::create('message')->setTitle('Message')->setValue('')->setMultiLine(TRUE), SelectOneField::create('category', 'User Category')->setSrc($categories)->setGrouper($grouper), SelectOneField::create('category2', 'User Category 2')->setSrc($categories)->setGrouper($grouper2));
$nameValidator = new TextValidator();
$nameValidator->required = FALSE;
$nameValidator->minLength = 3;
$nameValidator->setMaxLength = 12;
$surnameValidator = new RequiredValidator();
$surnameValidator->required = TRUE;
$requiredValidator = new BooleanValidator();
$requiredValidator->mustBeTrue = TRUE;
$validator = new SimpleValidator($form);
$validator->set('name', $nameValidator);
$validator->set('surname', $surnameValidator);
$validator->set('rememberMyRadio', $requiredValidator);
$validator->set('message', $requiredValidator);
$form->setValidator($validator);
$data = array();
if ($form->wasSubmitted()) {
    $data = $form->data;
}
include dirname(__FILE__) . '/themes/bootstrap/templates/index.phtml';
コード例 #3
0
ファイル: loginform.php プロジェクト: realholgi/formobject
use FormObject\Validator\SimpleValidator;
use FormObject\Validator\TextValidator;
use FormObject\Validator\BooleanValidator;
use FormObject\Validator\RequiredValidator;
Registry::getRenderer()->addPath(dirname(__FILE__) . '/themes/bootstrap/templates/forms');
/**
 * @brief ...
 * @var \FormObject\Form
 */
$form = Form::create();
$form->push(TextField::create('login')->setTitle('Please enter your name')->setValue('admin'), PasswordField::create('surname')->setTitle('Please enter your surname')->setValue(''), CheckboxField::create('rememberMe')->setTitle('Remember Me'));
$nameValidator = new TextValidator();
$nameValidator->required = FALSE;
$nameValidator->minLength = 3;
$nameValidator->setMaxLength = 12;
$requiredValidator = new RequiredValidator();
$requiredValidator->required = TRUE;
$trueValidator = new BooleanValidator();
$trueValidator->mustBeTrue = TRUE;
$validator = new SimpleValidator($form);
$validator->set('login', $nameValidator);
$validator->set('surname', $requiredValidator);
// $validator->set('rememberMyRadio', $trueValidator);
// $validator->set('category', $requiredValidator);
$form->setValidator($validator);
$form->fillByGlobals();
$data = array();
if ($form->wasSubmitted()) {
    $data = $form->data;
}
include dirname(__FILE__) . '/themes/bootstrap/templates/index.phtml';
コード例 #4
0
$targets = array('firstchild' => 'First Child Page', '1' => 'Home', '2' => 'Contact', '3' => 'About us');
$pages = SelectOneField::create('internalTarget', 'Target')->setSrc($targets);
$selectGroup->push($pages);
$externalTarget = TextField::create('externalTarget', 'URL');
$selectGroup->push($externalTarget);
$container2->push($selectGroup);
$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;
$validator = new SimpleValidator($form);
$validator->set('name', $nameValidator);
$validator->set('surname', $requiredValidator);
$validator->set('linkType', $requiredValidator);
$validator->set('rememberMyRadio', $trueValidator);
$validator->set('internalTarget', $requiredValidator);
$validator->set('externalTarget', $nameValidator);
$form->setValidator($validator);
$form->fillByGlobals();
$data = array();
if ($form->wasSubmitted()) {
    $data = $form->data;
}
include dirname(__FILE__) . '/themes/bootstrap/templates/index.phtml';
コード例 #5
0
ファイル: fieldgroup.php プロジェクト: realholgi/formobject
$rememberMyRadio->falseString = 'Forget my Radio';
$rememberMyRadio->setValue(TRUE);
$container = new FieldList('group1', 'Group One');
$form->push($container);
$container->push($name)->push($surname)->push($rememberMe)->push($rememberMyRadio);
$category = new SelectOneField('category', 'User Category');
$category->setSrc(array(1 => 'Customer', 2 => 'Co-Worker', 3 => 'Family', 4 => 'Organisation', 5 => 'Prospect'))->setValue(2);
$container2 = new FieldList('group2', 'Group Two');
$container2->push($category);
$form->push($container2);
$form('surname')->setValue('Hunter');
$nameValidator = new TextValidator();
$nameValidator->required = FALSE;
$nameValidator->minLength = 3;
$nameValidator->setMaxLength = 12;
$requiredValidator = new RequiredValidator();
$requiredValidator->required = TRUE;
$trueValidator = new BooleanValidator();
$trueValidator->mustBeTrue = TRUE;
$validator = new SimpleValidator($form);
$validator->set('name', $nameValidator);
$validator->set('surname', $requiredValidator);
$validator->set('rememberMyRadio', $trueValidator);
$validator->set('category', $requiredValidator);
$form->setValidator($validator);
$form->fillByGlobals();
$data = array();
if ($form->wasSubmitted()) {
    $data = $form->data;
}
include dirname(__FILE__) . '/themes/bootstrap/templates/index.phtml';
コード例 #6
0
ファイル: one2many.php プロジェクト: realholgi/formobject
    }
}
$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;
}
include dirname(__FILE__) . '/themes/bootstrap/templates/index.phtml';