/**
  * Constructor
  *
  * @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
  * @param string $name The method on the controller that will return this form object.
  * @param FieldList|FormField $fields All of the fields in the form - a {@link FieldList} of
  * {@link FormField} objects.
  * @param FieldList|FormAction $actions All of the action buttons in the form - a {@link FieldList} of
  */
 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } else {
         $backURL = Session::get('BackURL');
     }
     if (!$fields) {
         $fields = new FieldList();
         // Security/changepassword?h=XXX redirects to Security/changepassword
         // without GET parameter to avoid potential HTTP referer leakage.
         // In this case, a user is not logged in, and no 'old password' should be necessary.
         if (Member::currentUser()) {
             $fields->push(new PasswordField("OldPassword", _t('Member.YOUROLDPASSWORD', "Your old password")));
         }
         $fields->push(new PasswordField("NewPassword1", _t('Member.NEWPASSWORD', "New Password")));
         $fields->push(new PasswordField("NewPassword2", _t('Member.CONFIRMNEWPASSWORD', "Confirm New Password")));
     }
     if (!$actions) {
         $actions = new FieldList(new FormAction("doChangePassword", _t('Member.BUTTONCHANGEPASSWORD', "Change Password")));
     }
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
         $helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>');
         $importer = new MemberCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', DBField::create_field('HTMLFragment', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>'))));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
         $action->addExtraClass('btn btn-secondary-outline ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/vendor.js');
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberImportForm.js');
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css');
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('GroupImportForm.Help1', '<p>Import one or more groups in <em>CSV</em> format (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
         $helpHtml .= _t('GroupImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the ' . 'imported file</li>' . '<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>' . '<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not ' . 'cleared.</li>' . '</ul>' . '</div>');
         $importer = new GroupCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', DBField::create_field('HTMLFragment', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>'))));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
 /** @skipUpgrade */
 function __construct($controller = null, $name = 'Form')
 {
     if (empty($controller)) {
         $controller = new UploadFieldTest_Controller();
     }
     $fieldRootFolder = UploadField::create('RootFolderTest')->setFolderName('/');
     $fieldNoRelation = UploadField::create('NoRelationField')->setFolderName('UploadedFiles');
     $fieldHasOne = UploadField::create('HasOneFile')->setFolderName('UploadedFiles');
     $fieldHasOneExtendedFile = UploadField::create('HasOneExtendedFile')->setFolderName('UploadedFiles');
     $fieldHasOneMaxOne = UploadField::create('HasOneFileMaxOne')->setFolderName('UploadedFiles')->setAllowedMaxFileNumber(1);
     $fieldHasOneMaxTwo = UploadField::create('HasOneFileMaxTwo')->setFolderName('UploadedFiles')->setAllowedMaxFileNumber(2);
     $fieldHasMany = UploadField::create('HasManyFiles')->setFolderName('UploadedFiles');
     $fieldHasManyMaxTwo = UploadField::create('HasManyFilesMaxTwo')->setFolderName('UploadedFiles')->setAllowedMaxFileNumber(2);
     $fieldManyMany = UploadField::create('ManyManyFiles')->setFolderName('UploadedFiles');
     $fieldHasManyNoView = UploadField::create('HasManyNoViewFiles')->setFolderName('UploadedFiles');
     $fieldHasManyDisplayFolder = UploadField::create('HasManyDisplayFolder')->setFolderName('UploadedFiles')->setDisplayFolderName('UploadFieldTest');
     /** @skipUpgrade */
     $fieldReadonly = UploadField::create('ReadonlyField')->setFolderName('UploadedFiles')->performReadonlyTransformation();
     $fieldDisabled = UploadField::create('DisabledField')->setFolderName('UploadedFiles')->performDisabledTransformation();
     $fieldSubfolder = UploadField::create('SubfolderField')->setFolderName('UploadedFiles/subfolder1');
     $fieldCanUploadFalse = UploadField::create('CanUploadFalseField')->setCanUpload(false);
     $fieldCanAttachExisting = UploadField::create('CanAttachExistingFalseField')->setCanAttachExisting(false);
     $fieldAllowedExtensions = new UploadField('AllowedExtensionsField');
     $fieldAllowedExtensions->getValidator()->setAllowedExtensions(array('txt'));
     $fieldInvalidAllowedExtensions = new UploadField('InvalidAllowedExtensionsField');
     $fieldInvalidAllowedExtensions->getValidator()->setAllowedExtensions(array('txt', 'php'));
     $fields = new FieldList($fieldRootFolder, $fieldNoRelation, $fieldHasOne, $fieldHasOneMaxOne, $fieldHasOneMaxTwo, $fieldHasOneExtendedFile, $fieldHasMany, $fieldHasManyMaxTwo, $fieldManyMany, $fieldHasManyNoView, $fieldHasManyDisplayFolder, $fieldReadonly, $fieldDisabled, $fieldSubfolder, $fieldCanUploadFalse, $fieldCanAttachExisting, $fieldAllowedExtensions, $fieldInvalidAllowedExtensions);
     $actions = new FieldList(new FormAction('submit'));
     $validator = new RequiredFields();
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->loadDataFrom($this->getRecord());
 }
 /** @skipUpgrade */
 function __construct($controller = null, $name = 'Form')
 {
     if (empty($controller)) {
         $controller = new AssetFieldTest_Controller();
     }
     $fields = new FieldList(AssetField::create('File')->setFolderName('MyFiles'), AssetField::create('Image')->setAllowedFileCategories('image/supported')->setFolderName('MyImages'), AssetField::create('NoRelationField')->setFolderName('MyDocuments'));
     $actions = new FieldList(new FormAction('submit'));
     $validator = new RequiredFields();
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->loadDataFrom($this->getRecord());
 }
 public function __construct()
 {
     parent::__construct(Controller::curr(), __CLASS__, new FieldList(new TextField('Email'), new TextField('Surname'), new TextField('ID'), new TextField('FirstName')), new FieldList(new FormAction('someAction')));
 }
 public function __construct($controller, $name)
 {
     $fields = singleton('GroupTest_Member')->getCMSFields();
     $actions = new FieldList(new FormAction('doSave', 'save'));
     parent::__construct($controller, $name, $fields, $actions);
 }