public function createFields()
 {
     $parentFields = parent::createFields();
     $securityFields = new FieldList('security', trans('cmsable::forms.page-form.security'));
     $securityFields->setSwitchable(TRUE);
     $permFinder = App::make(__NAMESPACE__ . '\\PermissionFinder', array($this));
     $viewPermissions = $permFinder->buildFormValues($permFinder->getViewPermissions());
     $editPermissions = $permFinder->buildFormValues($permFinder->getEditPermissions());
     $deletePermissions = $permFinder->buildFormValues($permFinder->getDeletePermissions());
     $addChildPermissions = $permFinder->buildFormValues($permFinder->getAddChildPermissions());
     $securityFields->push(SelectOneField::create('view_permission')->setTitle(trans('cmsable::models.page.fields.view_permission'))->setSrc($viewPermissions), SelectOneField::create('edit_permission')->setTitle(trans('cmsable::models.page.fields.edit_permission'))->setSrc($editPermissions));
     $parentFields->push($securityFields);
     return $parentFields;
 }
Beispiel #2
0
 protected function getSettingFields()
 {
     $settingFields = new FieldList('settings', trans('cmsable::forms.page-form.settings'));
     $settingFields->setSwitchable(TRUE);
     $settingFields->push($this->createPageTypeField());
     if ($this->hasVisibilityField()) {
         $options = [trans('cmsable::models.page.enums.visibility.show_in_menu'), trans('cmsable::models.page.enums.visibility.show_in_aside_menu'), trans('cmsable::models.page.enums.visibility.show_in_search'), trans('cmsable::models.page.enums.visibility.show_when_authorized')];
         $settingFields->push(SelectFlagsField::create('visibility')->setTitle(trans('cmsable::models.page.fields.visibility'))->setSrc($options));
     } else {
         $settingFields->push(CheckboxField::create('show_in_menu')->setTitle(trans('cmsable::models.page.fields.show_in_menu')), CheckboxField::create('show_in_aside_menu')->setTitle(trans('cmsable::models.page.fields.show_in_aside_menu')), CheckboxField::create('show_in_search')->setTitle(trans('cmsable::models.page.fields.show_in_search')));
     }
     return $settingFields;
 }
Beispiel #3
0
 protected function createActionList($actionName = '', $actionTitle = '')
 {
     $actions = new FieldList();
     $actions->setForm($this);
     if (!$actionName && !$actionTitle) {
         return $actions;
     }
     $action = Action::create($actionName);
     if ($actionTitle) {
         $action->setTitle($actionTitle);
     }
     $actions->push($action);
     return $actions;
 }
Beispiel #4
0
 public function __construct($name = NULL, $title = NULL)
 {
     parent::__construct($name, $title);
     $this->setSwitchable(TRUE);
     $this->manualExtractor = new Extractor(Extractor::KEY, Extractor::VALUE);
 }
$form = Form::create($factory);
$form->setMethod(Form::GET);
$name = new TextField('name', 'Please enter your name');
$name->setValue('Jennifer');
$surname = new TextField('surname', 'Please enter your surname');
$surname->setValue('Batten');
$rememberMe = new CheckboxField('remember', 'Remember Me');
$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);
$container2 = new FieldList('group2', 'Tab Two');
$container2->setSwitchable(TRUE);
// $container2->push($category)->push($tagsField)->push($category2)->push($tags2);
$linkTypes = array('internal' => 'Internal', 'external' => 'External');
$selectGroup = SelectOneGroup::create('linkType', 'Link')->setSrc($linkTypes);
$selectGroup->setValue('internal');
$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();
Beispiel #6
0
$form->setMethod(Form::GET);
$name = new TextField('name', 'Please enter your name');
$name->setValue('Jennifer');
$surname = new TextField('surname', 'Please enter your surname');
$surname->setValue('Batten');
$rememberMe = new CheckboxField('remember', 'Remember Me');
$rememberMyRadio = new BooleanRadioField('rememberMyRadio');
$rememberMyRadio->trueString = 'Remember my Radio';
$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);
Beispiel #7
0
$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;
$validator = new SimpleValidator($form);
$validator->set('name', $nameValidator);