FieldList PHP Class Code Examples

This page contains top rated real world PHP examples of class FieldList extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: KapostBridgeLogViewer.php Project: helpfulrobot/webbuilders-group-silverstripe-kapost-bridge-logger
0
 /**
  * Form used for displaying the currently logged items
  */
 public function LogsForm()
 {
     $fields = new FieldList(DropdownField::create('CalledMethod', _t('KapostBridgeLogViewer.CALLED_METHOD', '_Called Method'), array('blogger.getUsersBlogs' => 'blogger.getUsersBlogs', 'kapost.getPreview' => 'kapost.getPreview', 'metaWeblog.editPost' => 'metaWeblog.editPost', 'metaWeblog.getCategories' => 'metaWeblog.getCategories', 'metaWeblog.getPost' => 'metaWeblog.getPost', 'metaWeblog.newMediaObject' => 'metaWeblog.newMediaObject', 'metaWeblog.newPost' => 'metaWeblog.newPost', 'system.listMethods' => 'system.listMethods'))->setEmptyString('--- ' . _t('KapostBridgeLogViewer.FILTER_BY_METHOD', '_Filter by Method') . ' ---'), $startDate = new DatetimeField('LogStartDate', _t('KapostBridgeLogViewer.START_DATE_TIME', '_Start Date/Time')), $endDate = new DatetimeField('LogEndDate', _t('KapostBridgeLogViewer.END_DATE_TIME', '_End Date/Time')));
     $startDate->getDateField()->setConfig('showcalendar', true);
     $endDate->getDateField()->setConfig('showcalendar', true);
     $actions = new FieldList(FormAction::create('doApplyFilters', _t('KapostBridgeLogViewer.APPLY_FILTER', '_Apply Filter'))->addExtraClass('ss-ui-action-constructive')->setUseButtonTag(true), Object::create('ResetFormAction', 'clear', _t('KapostBridgeLogViewer.RESET', '_Reset'))->setUseButtonTag(true));
     $form = new Form($this, 'LogsForm', $fields, $actions);
     $form->addExtraClass('log-search-form')->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->unsetValidator();
     // Load the form with previously sent search data
     $getVars = $this->request->getVars();
     //Workaround for start date field with no date or time
     if (array_key_exists('LogStartDate', $getVars)) {
         if (array_key_exists('date', $getVars['LogStartDate']) && !array_key_exists('time', $getVars['LogStartDate'])) {
             $getVars['LogStartDate']['time'] = '00:00:00';
         } else {
             if (!array_key_exists('date', $getVars['LogStartDate']) && array_key_exists('time', $getVars['LogStartDate'])) {
                 unset($getVars['LogStartDate']);
                 //Remove if there is no date present
             }
         }
     }
     //Workaround for end date field with no date or time
     if (array_key_exists('LogEndDate', $getVars)) {
         if (array_key_exists('date', $getVars['LogEndDate']) && !array_key_exists('time', $getVars['LogEndDate'])) {
             $getVars['LogEndDate']['time'] = '23:59:59';
         } else {
             if (!array_key_exists('date', $getVars['LogEndDate']) && array_key_exists('time', $getVars['LogEndDate'])) {
                 unset($getVars['LogEndDate']);
                 //Remove if there is no date present
             }
         }
     }
     $form->loadDataFrom($getVars);
     return $form;
 }
Example #2
Show file File: MemberImportForm.php Project: ivoba/silverstripe-framework
0
 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', _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);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js');
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
Example #3
Show file File: EVCSelectPage.php Project: sunnysideup/silverstripe-electric-vehicle-calculator
0
 function SelectForm()
 {
     $fieldList = new FieldList(NumericField::create("Year", "Manufacturing Year"), DropdownField::create("Make", "Make", array(0 => $this->pleaseSelectPhrase())), DropdownField::create("Model", "Model", array(0 => $this->pleaseSelectPhrase())), DropdownField::create("Type", "Type", array(0 => $this->pleaseSelectPhrase())), NumericField::create("ODO", "Current Odometer (overall distance travelled - as shown in your dashboard"));
     $actions = new FieldList(FormAction::create("doselectform")->setTitle("Start Calculation"));
     $form = Form::create($this, "SelectForm", $fieldList, $actions);
     return $form;
 }
Example #4
Show file File: RealMeLoginForm.php Project: helpfulrobot/silverstripe-realme
0
 /**
  * Returns an instance of this class
  *
  * @param Controller $controller
  * @param string $name
  */
 public function __construct($controller, $name)
 {
     $fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class)));
     $actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent('<span class="realme_button_padding">Login or register with RealMe<span class="realme_icon_new_window"></span> <span class="realme_icon_padlock"></span>')->setAttribute('class', 'realme_button')));
     // Taken from MemberLoginForm
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } elseif (Session::get('BackURL')) {
         $backURL = Session::get('BackURL');
     }
     if (isset($backURL)) {
         // Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page
         if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) {
             $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
         }
     }
     // optionally include requirements {@see /realme/_config/config.yml}
     if ($this->config()->include_jquery) {
         Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
     }
     if ($this->config()->include_javascript) {
         Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js");
     }
     if ($this->config()->include_css) {
         Requirements::css(REALME_MODULE_PATH . "/css/realme.css");
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
Example #5
Show file File: GoogleAuthenticatorLoginForm.php Project: helpfulrobot/xpointo-silverstripe-google-authenticator
0
 /**
  * Taken from MemberLoginForm::__construct with minor changes
  */
 public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $customCSS = project() . '/css/member_login.css';
     if (Director::fileExists($customCSS)) {
         Requirements::css($customCSS);
     }
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } else {
         $backURL = Session::get('BackURL');
     }
     if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
         $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
         $actions = new FieldList(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
     } else {
         if (!$fields) {
             $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
         }
         if (!$actions) {
             $actions = new FieldList(new FormAction('dologin', _t('GoogleAuthenticator.BUTTONLOGIN', "Log in with Google")));
         }
     }
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     // Allow GET method for callback
     $this->setFormMethod('GET', true);
     parent::__construct($controller, $name, $fields, $actions);
 }
Example #6
Show file File: JobBoardForm.php Project: helpfulrobot/fullscreeninteractive-silverstripe-jobboard
0
 /**
  * @param Controller $controller
  * @param Job $job (optional)
  */
 public function __construct($controller, $job = null)
 {
     if ($job) {
         $fields = $job->getFields();
         $required = $job->getValidator();
     } else {
         $fields = singleton('Job')->getFields();
         $required = singleton('Job')->getValidator();
     }
     $fields->merge(new FieldList(new LiteralField('Conditions', $controller->TermsAndConditionsText), new HiddenField('BackURL', '', $controller->Link('thanks')), new HiddenField('EmailFrom', '', $controller->getJobEmailFromAddress()), new HiddenField('EmailSubject', '', $controller->getJobEmailSubject()), $jobId = new HiddenField('JobID')));
     if ($job) {
         $jobId->setValue($job->ID);
         $actions = new FieldList(new FormAction('doEditJob', _t('Jobboard.EDITLISTING', 'Edit Listing')));
     } else {
         $actions = new FieldList(new FormAction('doAddJob', _t('JobBoard.CONFIRM', 'Confirm')));
     }
     parent::__construct($controller, 'AddJobForm', $fields, $actions, $required);
     $this->setFormAction('JobBoardFormProcessor/doJobForm');
     $this->setFormMethod('POST');
     if ($job) {
         $this->loadDataFrom($job);
     } else {
         $this->enableSpamProtection();
     }
 }
Example #7
Show file File: PollForm.php Project: helpfulrobot/mateusz-silverstripe-polls
0
 function __construct($controller, $name, $poll)
 {
     if (!$poll) {
         user_error("The poll doesn't exist.", E_USER_ERROR);
     }
     $this->poll = $poll;
     $data = array();
     foreach ($poll->Choices() as $choice) {
         $data[$choice->ID] = $choice->Title;
     }
     if ($poll->MultiChoice) {
         $choiceField = new CheckboxSetField('PollChoices', '', $data);
     } else {
         $choiceField = new OptionsetField('PollChoices', '', $data);
     }
     $fields = new FieldList($choiceField);
     if (PollForm::$show_results_link) {
         $showResultsURL = Director::get_current_page()->Link() . '?poll_results';
         $showResultsLink = new LiteralField('ShowPollLink', '<a class="show-results" href="' . $showResultsURL . '">Show results</a>');
         $fields->push($showResultsLink);
     }
     $actions = new FieldList(new FormAction('submitPoll', 'Submit', null, null, 'button'));
     $validator = new PollForm_Validator('PollChoices');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
Example #8
Show file File: BootstrapAjaxModalForm.php Project: spekulatius/silverstripe-bootstrap_extra_fields
0
 public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null, $Title = '', BootstrapModalFormAction $ModalFormAction)
 {
     parent::__construct($controller, $name, $fields, $actions, $validator, $Title, $ModalFormAction);
     Requirements::block('BootstrapModalForm_hasErrorJs_' . $this->FormName());
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-form/jquery.form.js');
     $name = $this->FormName();
     $action = $this->FormAction();
     $loading = _t('BootstrapAjaxModalForm.LOADING', 'BootstrapAjaxModalForm.LOADING');
     $js = <<<JS
nction(\$){
 \$(function(){
     \$('#{$name}').ajaxForm({
         delegation: true,
         target: '#Modal_{$name} .modal-dialog .modal-content',
         beforeSubmit: function(data, form, options){
             \$('#{$name} [type=submit]').prop("disabled", true).html('{$loading}');
         }
);
 });
 
 \$(function(){
     \$('#Modal_{$name}').on('show.bs.modal', function(e){
         \$('#Modal_{$name} .modal-dialog .modal-content').load('{$action}');
     });
     \$('#Modal_{$name}').on('hidden.bs.modal', function(e){
         \$('#Modal_{$name} .modal-dialog .modal-content').html('');
     });
 });
jQuery);

     Requirements::customScript($js, 'BootstrapAjaxModalForm_Js_' . $this->FormName());
     if (Director::is_ajax()) {
         $this->setTemplate('BootstrapAjaxModalForm');
     }
 }
Example #9
Show file File: BlogFrontEndForm_BlogController.php Project: helpfulrobot/i-lateral-silverstripe-blog-frontend
0
 /**
  * A simple form for creating blog entries
  */
 function FrontEndPostForm()
 {
     if ($this->owner->request->latestParam('ID')) {
         $id = (int) $this->owner->request->latestParam('ID');
     } else {
         $id = 0;
     }
     $membername = Member::currentUser() ? Member::currentUser()->getName() : "";
     // Set image upload
     $uploadfield = UploadField::create('FeaturedImage', _t('BlogFrontEnd.ShareImage', "Share an image"));
     $uploadfield->setCanAttachExisting(false);
     $uploadfield->setCanPreviewFolder(false);
     $uploadfield->setAllowedFileCategories('image');
     $uploadfield->relationAutoSetting = false;
     if (BlogFrontEnd::config()->allow_wysiwyg_editing) {
         $content_field = TrumbowygHTMLEditorField::create("Content", _t("BlogFrontEnd.Content"));
     } else {
         $content_field = TextareaField::create("Content", _t("BlogFrontEnd.Content"));
     }
     $form = new Form($this->owner, 'FrontEndPostForm', $fields = new FieldList(HiddenField::create("ID", "ID"), TextField::create("Title", _t('BlogFrontEnd.Title', "Title")), $uploadfield, $content_field), $actions = new FieldList(FormAction::create('doSavePost', _t('BlogFrontEnd.PostEntry', 'Post Entry'))), new RequiredFields('Title'));
     $uploadfield->setForm($form);
     if ($this->owner->Categories()->exists()) {
         $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.PostUnderCategories", "Post this in a category? (optional)"), $this->owner->Categories()->map()));
     }
     if ($this->owner->Tags()->exists()) {
         $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.AddTags", "Add a tag? (optional)"), $this->owner->Tags()->map()));
     }
     if ($id && ($post = BlogPost::get()->byID($id))) {
         $form->loadDataFrom($post);
     }
     $this->owner->extend("updateFrontEndPostForm", $form);
     return $form;
 }
Example #10
Show file File: CartForm.php Project: helpfulrobot/silvershop-core
0
 public function __construct($controller, $name = "CartForm", $cart = null, $template = "Cart")
 {
     $this->cart = $cart;
     $fields = new FieldList(CartEditField::create("Items", "", $this->cart)->setTemplate($template));
     $actions = new FieldList(FormAction::create("updatecart", "Update Cart"));
     parent::__construct($controller, $name, $fields, $actions);
 }
Example #11
Show file File: Rapid.php Project: helpfulrobot/internetrix-silverstripe-payment-eway
0
 /**
  * Return the payment form
  */
 public function PayForm()
 {
     $request = $this->getRequest();
     $response = Session::get('EwayResponse');
     $months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
     $years = range(date('y'), date('y') + 10);
     //Note: years beginning with 0 might cause issues
     $amount = $response->Payment->TotalAmount;
     $amount = number_format($amount / 100, 2);
     $currency = $response->Payment->CurrencyCode;
     $fields = new FieldList(HiddenField::create('EWAY_ACCESSCODE', '', $response->AccessCode), TextField::create('PayAmount', 'Amount', $amount . ' ' . $currency)->setDisabled(true), $nameField = TextField::create('EWAY_CARDNAME', 'Card holder'), $numberField = TextField::create('EWAY_CARDNUMBER', 'Card Number'), $expMonthField = DropdownField::create('EWAY_CARDEXPIRYMONTH', 'Expiry Month', array_combine($months, $months)), $expYearField = DropdownField::create('EWAY_CARDEXPIRYYEAR', 'Expiry Year', array_combine($years, $years)), $cvnField = TextField::create('EWAY_CARDCVN', 'CVN Number'), HiddenField::create('FormActionURL', '', $response->FormActionURL));
     //Test data
     if (Director::isDev()) {
         $nameField->setValue('Test User');
         $numberField->setValue('4444333322221111');
         $expMonthField->setValue('12');
         $expYearField->setValue(date('y') + 1);
         $cvnField->setValue('123');
     }
     $actions = new FieldList(FormAction::create('', 'Process'));
     $form = new Form($this, 'PayForm', $fields, $actions);
     $form->setFormAction($response->FormActionURL);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript('payment-eway/javascript/eway-form.js');
     $this->extend('updatePayForm', $form);
     return $form;
 }
Example #12
Show file File: ChangePasswordForm.php Project: ivoba/silverstripe-framework
0
 /**
  * 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);
 }
Example #13
Show file File: CalendarsForm.php Project: helpfulrobot/titledk-silverstripe-calendar
0
 /**
  * Contructor
  * @param type $controller
  * @param type $name
  */
 function __construct($controller, $name)
 {
     //Administering calendars
     if (CalendarConfig::subpackage_enabled('calendars')) {
         //Configuration for calendar grid field
         $gridCalendarConfig = GridFieldConfig_RecordEditor::create();
         $gridCalendarConfig->removeComponentsByType('GridFieldDataColumns');
         $gridCalendarConfig->addComponent($dataColumns = new GridFieldDataColumns(), 'GridFieldEditButton');
         $c = singleton('Calendar');
         $summaryFields = $c->summaryFields();
         //$summaryFields = array(
         //	'Title' => 'Title',
         //	//'SubscriptionOptIn' => 'Opt In',
         //	//'Shaded' => 'Shaded'
         //);
         $s = CalendarConfig::subpackage_settings('calendars');
         //show shading info in the gridfield
         if ($s['shading']) {
             $summaryFields['Shaded'] = 'Shaded';
         }
         $dataColumns->setDisplayFields($summaryFields);
         //settings for the case that colors are enabled
         if ($s['colors']) {
             $dataColumns->setFieldFormatting(array("Title" => '<div style=\\"height:20px;width:20px;display:inline-block;vertical-align:middle;margin-right:6px;background:$Color\\"></div> $Title'));
         }
         $GridFieldCalendars = new GridField('Calendars', '', PublicCalendar::get(), $gridCalendarConfig);
         $fields = new FieldList($GridFieldCalendars);
         $actions = new FieldList();
         $this->addExtraClass('CalendarsForm');
         parent::__construct($controller, $name, $fields, $actions);
     }
 }
Example #14
Show file File: SecurityAdmin.php Project: jacobbuck/silverstripe-framework
0
 public function getEditForm($id = null, $fields = null)
 {
     // TODO Duplicate record fetching (see parent implementation)
     if (!$id) {
         $id = $this->currentPageID();
     }
     $form = parent::getEditForm($id);
     // TODO Duplicate record fetching (see parent implementation)
     $record = $this->getRecord($id);
     if ($record && !$record->canView()) {
         return Security::permissionFailure($this);
     }
     $memberList = GridField::create('Members', false, Member::get(), $memberListConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldButtonRow('after'))->addComponent(new GridFieldExportButton('buttons-after-left')))->addExtraClass("members_grid");
     if ($record && method_exists($record, 'getValidator')) {
         $validator = $record->getValidator();
     } else {
         $validator = Member::singleton()->getValidator();
     }
     $memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator($validator);
     $groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
     $columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('Breadcrumbs' => singleton('SilverStripe\\Security\\Group')->fieldLabel('Title')));
     $columns->setFieldFormatting(array('Breadcrumbs' => function ($val, $item) {
         return Convert::raw2xml($item->getBreadcrumbs(' > '));
     }));
     $fields = new FieldList($root = new TabSet('Root', $usersTab = new Tab('Users', _t('SecurityAdmin.Users', 'Users'), new LiteralField('MembersCautionText', sprintf('<div class="alert alert-warning" role="alert">%s</div>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the database'))), $memberList), $groupsTab = new Tab('Groups', singleton('SilverStripe\\Security\\Group')->i18n_plural_name(), $groupList)), new HiddenField('ID', false, 0));
     // Add import capabilities. Limit to admin since the import logic can affect assigned permissions
     if (Permission::check('ADMIN')) {
         $fields->addFieldsToTab('Root.Users', array(new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('memberimport')))));
         $fields->addFieldsToTab('Root.Groups', array(new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('groupimport')))));
     }
     // Tab nav in CMS is rendered through separate template
     $root->setTemplate('CMSTabSet');
     // Add roles editing interface
     if (Permission::check('APPLY_ROLES')) {
         $rolesField = GridField::create('Roles', false, PermissionRole::get(), GridFieldConfig_RecordEditor::create());
         $rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
         $rolesTab->push($rolesField);
     }
     $actionParam = $this->getRequest()->param('Action');
     if ($actionParam == 'groups') {
         $groupsTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'users') {
         $usersTab->addExtraClass('ui-state-active');
     } elseif ($actionParam == 'roles') {
         $rolesTab->addExtraClass('ui-state-active');
     }
     $actions = new FieldList();
     $form = Form::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     // Tab nav in CMS is rendered through separate template
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $this->extend('updateEditForm', $form);
     return $form;
 }
Example #15
Show file File: UploadFieldTest.php Project: miamollie/echoAerial
0
 function __construct($controller = null, $name = 'Form')
 {
     if (empty($controller)) {
         $controller = new UploadFieldTest_Controller();
     }
     $fieldRootFolder = UploadField::create('RootFolderTest')->setFolderName('/');
     $fieldNoRelation = UploadField::create('NoRelationField')->setFolderName('UploadFieldTest');
     $fieldHasOne = UploadField::create('HasOneFile')->setFolderName('UploadFieldTest');
     $fieldHasOneExtendedFile = UploadField::create('HasOneExtendedFile')->setFolderName('UploadFieldTest');
     $fieldHasOneMaxOne = UploadField::create('HasOneFileMaxOne')->setFolderName('UploadFieldTest')->setAllowedMaxFileNumber(1);
     $fieldHasOneMaxTwo = UploadField::create('HasOneFileMaxTwo')->setFolderName('UploadFieldTest')->setAllowedMaxFileNumber(2);
     $fieldHasMany = UploadField::create('HasManyFiles')->setFolderName('UploadFieldTest');
     $fieldHasManyMaxTwo = UploadField::create('HasManyFilesMaxTwo')->setFolderName('UploadFieldTest')->setAllowedMaxFileNumber(2);
     $fieldManyMany = UploadField::create('ManyManyFiles')->setFolderName('UploadFieldTest');
     $fieldHasManyNoView = UploadField::create('HasManyNoViewFiles')->setFolderName('UploadFieldTest');
     $fieldHasManyDisplayFolder = UploadField::create('HasManyDisplayFolder')->setFolderName('UploadFieldTest')->setDisplayFolderName('UploadFieldTest');
     $fieldReadonly = UploadField::create('ReadonlyField')->setFolderName('UploadFieldTest')->performReadonlyTransformation();
     $fieldDisabled = UploadField::create('DisabledField')->setFolderName('UploadFieldTest')->performDisabledTransformation();
     $fieldSubfolder = UploadField::create('SubfolderField')->setFolderName('UploadFieldTest/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());
 }
Example #16
Show file File: CodeBankIPAgreement.php Project: helpfulrobot/undefinedoffset-silverstripe-codebank
0
 /**
  * Gets the form used for agreeing or disagreeing to the ip agreement
  * @param {int} $id ID of the record to fetch
  * @param {FieldList} $fields Fields to use
  * @return {Form} Form to be used
  */
 public function getEditForm($id = null, $fields = null)
 {
     $defaultPanel = Config::inst()->get('AdminRootController', 'default_panel');
     if ($defaultPanel == 'CodeBank') {
         $defaultPanel = 'SecurityAdmin';
         $sng = singleton($defaultPanel);
     }
     $fields = new FieldList(new TabSet('Root', new Tab('Main', new HeaderField('IPMessageTitle', _t('CodeBank.IP_MESSAGE_TITLE', '_You must agree to the following terms before using Code Bank'), 2), new LiteralField('IPMessage', '<div class="ipMessage"><div class="middleColumn">' . CodeBankConfig::CurrentConfig()->dbObject('IPMessage')->forTemplate() . '</div></div>'), new HiddenField('RedirectLink', 'RedirectLink', $sng->Link()))));
     if (Session::get('CodeBankIPAgreed') === true) {
         $fields->addFieldToTab('Root.Main', new HiddenField('AgreementAgreed', 'AgreementAgreed', Session::get('CodeBankIPAgreed')));
     }
     $actions = new FieldList(FormAction::create('doDisagree', _t('CodeBankIPAgreement.DISAGREE', '_Disagree'))->addExtraClass('ss-ui-action-destructive'), FormAction::create('doAgree', _t('CodeBankIPAgreement.AGREE', '_Agree'))->addExtraClass('ss-ui-action-constructive'));
     $form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
     $form->disableDefaultAction();
     $form->addExtraClass('cms-edit-form');
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     $form->addExtraClass('center ' . $this->BaseCSSClasses());
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     //Display message telling user to run dev/build because the version numbers are out of sync
     if (CB_VERSION != '@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version != CB_VERSION . ' ' . CB_BUILD_DATE) {
         $form->setMessage(_t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink' => '<a href="dev/build?flush=all">', 'endlink' => '</a>')), 'error');
     } else {
         if ($this->hasOldTables()) {
             $form->setMessage(_t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink' => '<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink' => '</a>')), 'warning');
         }
     }
     $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: ' . $this->getVersion() . '</p>'));
     Requirements::javascript(CB_DIR . '/javascript/CodeBank.IPMessage.js');
     return $form;
 }
Example #17
Show file File: TestFileUploadPage.php Project: helpfulrobot/silverstripe-frameworktest
0
 function Form()
 {
     $fields = new FieldList(new EmailField('Email', 'EmailField'), new FileField('AFile', 'FileField'), $aImage = new UploadField('AImage', 'SimpleImageField'));
     $aImage->allowedExtensions = array('jpg', 'gif', 'png');
     $actions = new FieldList(new FormAction('addMember', "Add a member with two Files uploaded"));
     return new Form($this, "Form", $fields, $actions);
 }
Example #18
Show file File: AddToCartPage.php Project: helpfulrobot/sunnysideup-ecommerce-quick-add
0
 function QuickAddToCartForm()
 {
     $fields = new FieldList(new HeaderField("SelectCustomer", _t("AddToCartPage.ADDPRODUCTS", "Add Products to your order")), new HiddenField("BuyableID"), new HiddenField("BuyableClassName"), new HiddenField("Version"), new BuyableSelectField("FindBuyable", _t("AddToCartPage.PRODUCT", "Product")), new NumericField("Quantity", _t("AddToCartPage.QUANTITY", "Quantity"), 1));
     $actions = new FieldList(new FormAction("quickaddtocartform_add", _t("AddToCartPage.ADD", "Add")));
     $validator = new RequiredFields(array("Quantity"));
     return new Form($this, "QuickAddToCartForm", $fields, $actions, $validator);
 }
Example #19
Show file File: FrontendEditing.php Project: helpfulrobot/gdmedia-silverstripe-frontend-admin
0
 public static function getUploadForm($file, $parentClass, $parentId, $parentField)
 {
     if ($file instanceof File && class_exists($parentClass) && is_subclass_of($parentClass, "DataObject")) {
         $parent = $parentClass::get()->byId($parentId);
         $fields = new FieldList($uploadField = new UploadField($parentField, 'Upload', $parent));
         $uploadField->setCanAttachExisting(false);
         // Block access to Silverstripe assets library
         $uploadField->setCanPreviewFolder(false);
         // Don't show target filesystem folder on upload field
         $uploadField->relationAutoSetting = false;
         // Prevents the form thinking the GalleryPage is the underlying object
         $uploadField->setFolderName('Address Book');
         $uploadField->setAllowedMaxFileNumber(1);
         if ($file instanceof Image) {
             $uploadField->setAllowedFileCategories('image');
         }
         $actions = new FieldList(new FormAction('submit', 'Save'));
         $from = new Form(Controller::curr(), 'feFileUploadForm', $fields, $actions, null);
         $urlParams = array('feclass' => $parentClass, 'fefield' => $parentField, 'feid' => $parentId, 'filesUpload' => true, 'fefileid' => $file->ID, 'fefileclass' => $file->ClassName);
         //   feclass: parentClass,
         //                        fefield: parentField,
         //                        feid: parentId,
         //                        feisUpload: true,
         //                        value: "{feclass: " + objClass + ",feid: " + objId + "}"
         //            echo http_build_query($urlParams) . "\n";
         $from->setFormAction('home/feFileUploadForm?' . http_build_query($urlParams));
         return $from;
     }
 }
Example #20
Show file File: MetaDataFieldAddForm.php Project: helpfulrobot/silverstripe-australia-metadata
0
 /**
  * @return Form
  */
 public function AddForm()
 {
     $fields = new FieldList(new LiteralField('SelectFieldType', '<p><strong>Please select a field type to add:</strong></p>'), $df = new DropdownField('ClassName', '', $this->getFieldTypes(), null, null));
     $df->setHasEmptyDefault(true);
     if ($schemaID = (int) $this->request->param('ID')) {
         $fields->push(new HiddenField('SchemaID', '', $schemaID));
     }
     $actions = new FieldList(FormAction::create('doAddField', 'Create')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
     // Add a Cancel link which is a button-like link and link back to one level up.
     $curmbs = $this->Breadcrumbs();
     if ($curmbs && $curmbs->count() >= 2) {
         $one_level_up = $curmbs->offsetGet($curmbs->count() - 2);
         $text = "\n\t\t\t<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"" . $one_level_up->Link . "\">\n\t\t\t\tCancel\n\t\t\t</a>";
         $actions->push(new LiteralField('cancelbutton', $text));
     }
     $form = new Form($this, 'AddForm', $fields, $actions);
     $toplevelController = $this->getToplevelController();
     $form->setTemplate('LeftAndMain_EditForm');
     $form->addExtraClass('cms-content cms-edit-form center ss-tabset stacked');
     $form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     //var_dump($this->popupController); die;
     $parents = $this->popupController->Breadcrumbs(false)->items;
     $form->Backlink = array_pop($parents)->Link;
     return $form;
 }
Example #21
Show file File: ExchangeRate.php Project: helpfulrobot/swipestripe-swipestripe-currency
0
 public function ExchangeRateSettingsForm()
 {
     $shopConfig = ShopConfig::get()->First();
     if (singleton($this->modelClass)->hasMethod('getCMSValidator')) {
         $detailValidator = singleton($this->modelClass)->getCMSValidator();
         $listField->getConfig()->getComponentByType('GridFieldDetailForm')->setValidator($detailValidator);
     }
     $config = GridFieldConfig_HasManyRelationEditor::create();
     $detailForm = $config->getComponentByType('GridFieldDetailForm')->setValidator(singleton('ExchangeRate')->getCMSValidator());
     if (class_exists('GridFieldSortableRows')) {
         $config->addComponent(new GridFieldSortableRows('SortOrder'));
     }
     $fields = new FieldList($rootTab = new TabSet('Root', $tabMain = new Tab('ExchangeRates', GridField::create('ExchangeRates', 'ExchangeRates', $shopConfig->ExchangeRates(), $config))));
     $actions = new FieldList();
     $actions->push(FormAction::create('saveExchangeRateSettings', _t('GridFieldDetailForm.Save', 'Save'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'add'));
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->setTemplate('ShopAdminSettings_EditForm');
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->addExtraClass('cms-content cms-edit-form center ss-tabset');
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->setFormAction(Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'ExchangeRate/ExchangeRateSettingsForm'));
     $form->loadDataFrom($shopConfig);
     return $form;
 }
Example #22
Show file File: BootstrapHorizontalForm.php Project: spekulatius/silverstripe-bootstrap_extra_fields
0
 public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
 {
     parent::__construct($controller, $name, $fields, $actions, $validator);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
     Requirements::javascript('bootstrap_extra_fields/javascript/tooltip.js');
     $this->setTemplate('BootstrapHorizontalForm')->addExtraClass('form-horizontal');
 }
Example #23
Show file File: StreamLineContactPage.php Project: helpfulrobot/chtombleson-silverstripe-streamline
0
 private function buildForm()
 {
     $contact_fields = $this->ContactFields();
     $fields = new FieldList();
     $required_fields = array();
     foreach ($contact_fields as $contact_field) {
         switch ($contact_field->Type) {
             case 'TextField':
                 $fields->add(new TextField($contact_field->Name, $contact_field->Name));
                 break;
             case 'EmailField':
                 $fields->add(new EmailField($contact_field->Name, $contact_field->Name));
                 break;
             case 'TextareaField':
                 $fields->add(new TextareaField($contact_field->Name, $contact_field->Name));
                 break;
             case 'DropdownField':
                 $values = explode("\n", $contact_field->Values);
                 $dropdown_values = array();
                 foreach ($values as $value) {
                     $dropdown_values[trim($value)] = trim($value);
                 }
                 $fields->add(new DropdownField($contact_field->Name, $contact_field->Name, $dropdown_values));
                 break;
         }
         if ($contact_field->Required) {
             $required_fields[] = $contact_field->Name;
         }
     }
     $actions = new FieldList(FormAction::create("doSubmitContactForm")->setTitle("Contact"));
     $required = new RequiredFields($required_fields);
     $form = new Form($this, 'ContactForm', $fields, $actions, $required);
     return $form;
 }
Example #24
Show file File: ContactPage.php Project: helpfulrobot/maldicore-travelagent
0
 public function Form()
 {
     $fields = new FieldList(new TextField('Name'), new EmailField('Email'), new TextareaField('Message'));
     $actions = new FieldList(new FormAction('submit', 'Submit'));
     $validator = new RequiredFields('Name', 'Email', 'Message');
     return new Form($this, 'Form', $fields, $actions, $validator);
 }
Example #25
Show file File: OrderModifierForm.php Project: helpfulrobot/sunnysideup-ecommerce
0
 /**
  *NOTE: we semi-enforce using the OrderModifier_Controller here to deal with the submission of the OrderModifierForm
  * You can use your own modifiers or an extension of OrderModifier_Controller by setting the first parameter (optionalController)
  * to your own controller.
  *
  *@param $optionalController Controller
  *@param $name String
  *@param $fields FieldList
  *@param $actions FieldList
  *@param $validator SS_Validator
  **/
 function __construct(Controller $optionalController = null, $name, FieldList $fields, FieldList $actions, Validator $optionalValidator = null)
 {
     if (!$optionalController) {
         $controllerClassName = EcommerceConfig::get("OrderModifierForm", "controller_class");
         $optionalController = new $controllerClassName();
     }
     if (!$optionalValidator) {
         $validatorClassName = EcommerceConfig::get("OrderModifierForm", "validator_class");
         $optionalValidator = new $validatorClassName();
     }
     parent::__construct($optionalController, $name, $fields, $actions, $optionalValidator);
     //extension point
     $this->extend('updateFields', $fields);
     $this->setFields($fields);
     $this->extend('updateActions', $actions);
     $this->setActions($actions);
     $this->extend('updateValidator', $optionalValidator);
     $this->setValidator($optionalValidator);
     $this->setAttribute("autocomplete", "off");
     Requirements::themedCSS($this->ClassName, 'ecommerce');
     $this->addExtraClass($this->myLcFirst(ucwords($name)));
     Requirements::javascript(THIRDPARTY_DIR . "/jquery-form/jquery.form.js");
     //add JS for the modifier - added in modifier
     $oldData = Session::get("FormInfo.{$this->FormName()}.data");
     if ($oldData && (is_array($oldData) || is_object($oldData))) {
         $this->loadDataFrom($oldData);
     }
     $this->extend('updateOrderModifierForm', $this);
 }
Example #26
Show file File: BootstrapAjaxForm.php Project: spekulatius/silverstripe-bootstrap_extra_fields
0
 public function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
 {
     parent::__construct($controller, $name, $fields, $actions, $validator);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-form/jquery.form.js');
     $name = $this->FormName();
     $action = $this->FormAction();
     $loading = _t('BootstrapAjaxForm.LOADING', 'BootstrapAjaxForm.LOADING');
     $js = <<<JS
nction(\$){
 \$(function(){
     \$('#{$name}').ajaxForm({
         delegation: true,
         target: '#AjaxForm_{$name}',
         beforeSubmit: function(data, form, options){
             \$('#{$name} [type=submit]').prop("disabled", true).html('{$loading}');
         }
);
 });
jQuery);

     Requirements::customScript($js, 'BootstrapAjaxForm_Js_' . $this->FormName());
     if (!Director::is_ajax()) {
         $this->setTemplate('BootstrapAjaxForm');
     }
 }
Example #27
Show file File: SetupForm.php Project: helpfulrobot/heyday-silverstripe-vend
0
 /**
  * @param \Controller $controller
  */
 public function __construct($controller, $name)
 {
     $this->addExtraClass('vend-form');
     $this->controller = $controller;
     $config = \SiteConfig::current_site_config();
     $vendToken = VendToken::get()->first();
     $vendAccessToken = $vendToken->AccessToken;
     $vendShopName = $config->VendShopName;
     $fields = new \FieldList();
     $actions = new \FieldList();
     $fields->add(new \LiteralField('vend', "<h1>Vend Integration</h1>"));
     if (!is_null($vendAccessToken) && !empty($vendAccessToken)) {
         $url = $this->getAuthURL();
         $fields->add(new \LiteralField('explanation', "<p>You're all setup!<br> If you need to reauthenticate, click <a href='{$url}' target='_blank'>here</a></p>"));
     } else {
         if (!is_null($vendShopName) && !empty($vendShopName)) {
             $url = $this->getAuthURL();
             $fields->add(new \LiteralField('explanation', "Please authenticate by clicking <a href='{$url}' target='_blank'>here</a>"));
         } else {
             $fields->add(new \LiteralField('explanation', "Please remember to set your app settings in a config file."));
         }
     }
     $fields->add(new \TextField('VendShopName', 'Vend Shop Name (yourshopname.vendhq.com)', $vendShopName));
     $actions->push(new \FormAction('doSave', 'Save'));
     // Reduce attack surface by enforcing POST requests
     $this->setFormMethod('POST', true);
     parent::__construct($controller, $name, $fields, $actions);
 }
Example #28
Show file File: SimpleCacheAdmin.php Project: helpfulrobot/silverstripe-australia-simplecache
0
 public function getEditForm($id = null, $fields = null)
 {
     $tabs = new TabSet('Root', new Tab('Main'));
     $fields = new FieldList($tabs);
     $caches = array();
     $all_caches = SimpleCache::$cache_configs;
     foreach ($all_caches as $name => $cacheInfo) {
         $cache = $this->getCache($name);
         if ($cache) {
             $stats = $cache->stats();
             $fields->addFieldToTab('Root.Main', new HeaderField($name . 'header', $name));
             $fields->addFieldToTab('Root.Main', new ReadonlyField($name . 'Hits', 'Hits', $stats->hits));
             $fields->addFieldToTab('Root.Main', new ReadonlyField($name . 'Miss', 'Miss', $stats->misses));
             $fields->addFieldToTab('Root.Main', new ReadonlyField($name . 'Count', 'Count', $stats->count));
             $caches[$name] = $name;
         }
     }
     if (count($caches)) {
         $fields->addFieldToTab('Root.Clear', new CheckboxSetField('ToClear', 'Caches to clear', $caches));
     }
     $actions = new FieldList(new FormAction('clear', 'Clear'));
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
     return $form;
 }
Example #29
Show file File: TrainingSignupForm.php Project: helpfulrobot/sunnysideup-traininglistingsandsignup
0
 function __construct($controller, $name, $title = "Training")
 {
     if ($member = Member::currentUser()) {
     } else {
         $member = new Member();
     }
     $fields = new FieldList(new HeaderField($title));
     $extraFields = $member->getTrainingFields();
     foreach ($extraFields as $field) {
         if ("Password" == $field->title() && $member->ID) {
         } elseif ("Password" == $field->title()) {
             $fields->push(new ConfirmedPasswordField("Password"));
         } else {
             $fields->push($field);
         }
     }
     $actions = new FieldList(new FormAction("doSave", "Sign Up Now"));
     $requiredFields = new RequiredFields("FirstName", "Surname", "Email", "Password");
     if ($controller->Options) {
         $array = array();
         $explodedOptions = explode(",", $controller->Options);
         foreach ($explodedOptions as $option) {
             $option = trim(Convert::raw2att($option));
             $array[$option] = $option;
         }
         if (count($array)) {
             $fields->push(new DropdownField("SelectedOption", "Select Option", $array));
         }
     }
     $fields->push(new TextField("BookingCode", "Booking Code (if any)"));
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     $this->loadNonBlankDataFrom($member);
     return $this;
 }
Example #30
Show file File: ContactPage.php Project: helpfulrobot/weboftalent-contactage
0
 function ContactForm()
 {
     error_log("Render form");
     $name = _t('ContactPage.NAME', 'Name');
     $email = _t('ContactPage.EMAIL', 'Email');
     $comments = _t('ContactPage.COMMENTS', 'Comments');
     $send = _t('ContactPage.SEND', 'Send');
     // Create fields
     $tf = new TextField('Name', $name);
     $tf->addExtraClass('span11');
     $ef = new EmailField('Email', $email);
     $ef->addExtraClass('span11');
     $taf = new TextareaField('Comments', $comments);
     $taf->addExtraClass('span11');
     $fields = new FieldList($tf, $ef, $taf);
     // Create action
     $fa = new FormAction('SendContactForm', $send);
     // for bootstrap
     $fa->useButtonTag = true;
     $fa->addExtraClass('btn btn-primary');
     $actions = new FieldList($fa);
     // Create action
     $validator = new RequiredFields('Name', 'Email', 'Comments');
     $form = new Form($this, 'ContactForm', $fields, $actions, $validator);
     $form->setTemplate('VerticalForm');
     $form->addExtraClass('well');
     return $form;
 }