• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Form类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Form的典型用法代码示例。如果您正苦于以下问题:PHP Form类的具体用法?PHP Form怎么用?PHP Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Form类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: edit

 /**
  * @abstract Displays and processes the edit news form
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     if (!files()->setUploadDirectory()) {
         sml()->say("The file upload directory does not appear to be writable. Please create the folder and set proper permissions.");
     }
     $form = new Form('news', $id);
     if (!$id) {
         $form->setCurrentValue('timestamp', date("Y-m-d H:i:s"));
     }
     // if form has been submitted
     if ($form->isSubmitted()) {
         $file = files()->upload('pdf_filename');
         if (is_array($file) && !empty($file[0])) {
             $form->setCurrentValue('pdf_filename', $file[0]['file_name']);
         }
         if ($form->save($id)) {
             sml()->say('News entry has successfully been updated.');
             router()->redirect('view');
         }
     }
     // make sure the template has access to all current values
     $data['form'] = $form;
     template()->addCss('admin/datepicker.css');
     template()->addJs('admin/datepicker.js');
     template()->addJs('edit.js');
     template()->display($data);
 }
开发者ID:viveleroi,项目名称:AspenMSM,代码行数:32,代码来源:News_Admin.php


示例2: setForm

 public function setForm(Form &$form, array $request)
 {
     $errors = array();
     $form->befor_set();
     $reflex = new ReflectionObject($form);
     $propts = $reflex->getParentClass()->getProperties();
     foreach ($propts as $propt) {
         $name = $propt->getName();
         $exis = method_exists($form, self::VALIDATE . $name);
         $value = isset($request[$name]) ? $request[$name] : null;
         $valid = self::VALIDATE . $name;
         $setvl = self::SET_METHOD . ucfirst($name);
         $respn = $exis ? $form->{$valid}($value) : true;
         if ($respn === true) {
             if (method_exists($form, $setvl)) {
                 if ($value != null) {
                     $form->{$setvl}($value);
                 }
             } else {
                 if ($value != null) {
                     $propt->setAccessible(true);
                     $propt->setValue($form, $value);
                     $propt->setAccessible(false);
                 }
             }
         } else {
             $errors[$name] = $respn;
         }
     }
     $form->after_set();
     return count($errors) > 0 ? $errors : true;
 }
开发者ID:exildev,项目名称:corvus,代码行数:32,代码来源:View.php


示例3: toBoolean

 public function toBoolean(Form $form)
 {
     $left = $form->toFormValue($this->left);
     $right = $form->toFormValue($this->right);
     $value = $form->toFormValue($this->field);
     return $left <= $value && $value <= $right;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:7,代码来源:LogicalBetween.class.php


示例4: post

 public function post($id = null)
 {
     if (empty($_POST)) {
         $this->_logger->debug("loading form at {$_SERVER['REQUEST_URI']}");
         if ($id !== null) {
             $post = $this->_factory->get('Post', $id);
             $this->view->aTitle = $post->title;
             $this->view->aBody = $post->body;
         }
         $this->view->display('blog/edit.tpl');
     } else {
         $this->_logger->debug("form at {$_SERVER['REQUEST_URI']} submitted");
         $validators = array('aTitle' => array('NotEmpty', 'messages' => 'Title is required'), 'aBody' => array('NotEmpty', 'messages' => 'Body is required'));
         $form = new Form($validators, $_POST);
         if (!$form->isValid()) {
             $this->_logger->debug("form at {$_SERVER['REQUEST_URI']} submitted but invalid");
             $this->view->assign($_POST);
             $this->view->assign($form->getMessages());
             $this->view->display('blog/edit.tpl');
         } else {
             $this->_logger->debug("form at {$_SERVER['REQUEST_URI']} successful ");
             $post = $this->_factory->get('Post', $id);
             $post->title = $form->getRaw('aTitle');
             $post->body = $form->getRaw('aBody');
             $post->create_dt_tm = date('Y-m-d H:i:s');
             $post->save();
             header('Location: /blog');
             exit;
         }
     }
 }
开发者ID:hellogerard,项目名称:pox-framework,代码行数:31,代码来源:BlogController.php


示例5: Form

 function Form()
 {
     $form = new Form($this, 'Form', new FieldList(new EmailField('Email')), new FieldList(new FormAction('doSubmit')), new RequiredFields('Email'));
     // Disable CSRF protection for easier form submission handling
     $form->disableSecurityToken();
     return $form;
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:7,代码来源:EmailFieldTest.php


示例6: saveNewsArticle

 function saveNewsArticle($data, Form $form)
 {
     try {
         $form->clearMessage();
         $form->resetValidation();
         if ($data['newsID']) {
             $this->manager->updateNews($data);
         } else {
             $this->manager->postNews($data);
         }
         Session::clear("FormInfo.Form_NewsRequestForm.data");
         return Controller::curr()->redirect('/news-add/?saved=1');
     } catch (EntityValidationException $ex1) {
         $messages = $ex1->getMessages();
         $msg = $messages[0];
         $form->addErrorMessage('Headline', $msg['message'], 'bad');
         SS_Log::log($msg['message'], SS_Log::ERR);
         // Load errors into session and post back
         Session::set("FormInfo.Form_NewsRequestForm.data", $data);
         return $this->redirectBack();
     } catch (Exception $ex) {
         $form->addErrorMessage('Headline', 'Server Error', 'bad');
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         // Load errors into session and post back
         Session::set("FormInfo.Form_NewsRequestForm.data", $data);
         return $this->redirectBack();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:28,代码来源:NewsRequestPage.php


示例7: _createForgotPassForm

 public function _createForgotPassForm()
 {
     $form = new Form();
     $form->action = "/forgotpass";
     $form->add(EmailField::name('email')->label('Email')->help('What is your email address?')->required(true));
     return $form;
 }
开发者ID:JoonasMelin,项目名称:BotQueue,代码行数:7,代码来源:auth.php


示例8: QuickDraftSave

 /**
  * Form Handler to save a content quick create.
  *
  * @param Form $form
  *
  * @return string|bool
  */
 public static function QuickDraftSave(Form $form)
 {
     if (!$form->getElementValue('title')) {
         \Core\set_message('All pages must have titles.', 'error');
         return false;
     }
     /** @var $model ContentModel */
     $model = new ContentModel();
     /** @var $page PageModel Page object for this model, already linked up! */
     $page = $model->getLink('Page');
     // The content nickname is derived from the page title.
     $model->set('nickname', $form->getElementValue('title'));
     $model->save();
     $ins = new InsertableModel();
     $ins->set('site', $page->get('site'));
     $ins->set('baseurl', '/content/view/' . $model->get('id'));
     $ins->set('name', 'body');
     $ins->set('value', '<p>' . nl2br($form->getElementValue('content')) . '</p>');
     $ins->save();
     $page->set('title', $form->getElementValue('title'));
     $page->set('published_status', 'draft');
     $page->set('editurl', '/content/edit/' . $model->get('id'));
     $page->set('deleteurl', '/content/delete/' . $model->get('id'));
     $page->set('component', 'content');
     $page->save();
     return true;
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:34,代码来源:ContentAdminWidget.php


示例9: updateEditForm

 public function updateEditForm(\Form $form)
 {
     $record = $form->getRecord();
     $fields = $form->Fields()->dataFields();
     $separator = HasOneEditDataObjectExtension::separator;
     foreach ($fields as $name => $field) {
         // Replace shortcuts for separator
         $name = str_replace(array(':', '/'), $separator, $name);
         if (!strpos($name, $separator)) {
             // Also skip $name that starts with a separator
             continue;
         }
         $field->setName($name);
         if (!$record) {
             // No record to set value from
             continue;
         }
         if ($field->Value()) {
             // Skip fields that already have a value
             continue;
         }
         list($hasone, $key) = explode($separator, $name, 2);
         if ($record->has_one($hasone) || $record->belongs_to($hasone)) {
             $rel = $record->getComponent($hasone);
             // Copied from loadDataFrom()
             $exists = isset($rel->{$key}) || $rel->hasMethod($key) || $rel->hasMethod('hasField') && $rel->hasField($key);
             if ($exists) {
                 $value = $rel->__get($key);
                 $field->setValue($value);
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:33,代码来源:HasOneEditUpdateFormExtension.php


示例10: generateFormID

 /**
  * @param Form $form
  *
  * @return string
  */
 public function generateFormID($form)
 {
     if ($id = $form->getHTMLID()) {
         return Convert::raw2htmlid($id);
     }
     return Convert::raw2htmlid(get_class($form) . '_' . str_replace(array('.', '/'), '', $form->getName()));
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:12,代码来源:FormTemplateHelper.php


示例11: _buildRegistrationForm

 protected function _buildRegistrationForm()
 {
     $Form = new Form('logon', $this->getRouter(), $this->getRequest());
     $Form->attach(new FormFieldset('personalInfo'));
     $Form->personalInfo->setLegend('Personal Info');
     $FormNoteInfo = new FormNote('info', FormNote::POSITIONRIGHT);
     $FormNoteInfo->addSection('First and Last Name', 'Enter your first and last name separately into the labeled text input boxes.');
     $FormNoteInfo->addSection('E-Mail Address', array('Enter a valid e-mail address into the labeled text input box; this value will also be your username to log onto this website.', 'Also note that to activate your account you will need to follow a link in an activation e-mail sent to this address. Make sure this is a valid e-mail.'));
     $FormNoteInfo->addSection('Password', 'You must enter a strong password that is at least six characters and contains at least one letter, one number, and one symbol.');
     $Form->personalInfo->attach($FormNoteInfo);
     $FormNoteUsage = new FormNote('logonmessage', FormNote::POSITIONNORMAL);
     $FormNoteUsage->addSection(false, 'Please completely fill out the below information. All fields are required.');
     $Form->personalInfo->attach($FormNoteUsage);
     $Form->personalInfo->attach(new FormInput('firstName', 'First Name'));
     $Form->personalInfo->firstName->restrict(new FormRestrictionNotEmpty());
     $Form->personalInfo->firstName->restrict(new FormRestrictionAlphanumeric());
     $Form->personalInfo->firstName->restrict(new FormRestrictionMaxLength(48));
     $Form->personalInfo->attach(new FormInput('lastName', 'Last Name'));
     $Form->personalInfo->lastName->restrict(new FormRestrictionNotEmpty());
     $Form->personalInfo->lastName->restrict(new FormRestrictionAlphanumeric());
     $Form->personalInfo->lastName->restrict(new FormRestrictionMaxLength(48));
     $Form->personalInfo->attach(new FormInput('email', 'E-Mail Address'));
     $Form->personalInfo->email->restrict(new FormRestrictionNotEmpty());
     $Form->personalInfo->email->restrict(new FormRestrictionEmail());
     $Form->personalInfo->email->restrict(new FormRestrictionMaxLength(48));
     $Form->personalInfo->attach(new FormInput('password', 'Password', 'password'));
     $Form->personalInfo->password->restrict(new FormRestrictionNotEmpty());
     $Form->personalInfo->password->restrict(new FormRestrictionMinLength(6));
     $Form->personalInfo->password->restrict(new FormRestrictionGoodPassword());
     $Form->personalInfo->attach(new FormInput('passwordc', 'Password (Confirm)', 'password'));
     $Form->personalInfo->passwordc->restrict(new FormRestrictionSameAsField($Form->personalInfo->password));
     $Form->personalInfo->attach(new FormInputSubmit('Register'));
     return $Form;
 }
开发者ID:robfrawley,项目名称:cad,代码行数:34,代码来源:ControllerRegister.php


示例12: updateLinkForm

 function updateLinkForm(Form $form)
 {
     $linkType = null;
     $fieldList = null;
     $fields = $form->Fields();
     //->fieldByName('Heading');
     foreach ($fields as $field) {
         $linkType = $field->fieldByName('LinkType');
         $fieldList = $field;
         if ($linkType) {
             break;
         }
         //break once we have the object
     }
     $source = $linkType->getSource();
     $source['document'] = 'Download a document';
     $linkType->setSource($source);
     $addExistingField = new DMSDocumentAddExistingField('AddExisting', 'Add Existing');
     $addExistingField->setForm($form);
     $addExistingField->setUseFieldClass(false);
     $fieldList->insertAfter($addExistingField, 'Description');
     //		Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
     //		Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js");
     //
     //		// create additional field, rebase to 'documents' directory
     //		$documents = new TreeDropdownField('document', 'Document', 'File', 'ID', 'DocumentDropdownTitle', true);
     //		$documents->setSearchFunction(array($this, 'documentSearchCallback'));
     //		$baseFolder = Folder::find_or_make(Document::$directory);
     //		$documents->setTreeBaseID($baseFolder->ID);
     //return $form;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-dms,代码行数:31,代码来源:DocumentHtmlEditorFieldToolbar.php


示例13: createUser

 /**
  * @param \Symfony\Component\Form\Form $form
  * @param \AppBundle\Entity\User $user
  * @return bool
  */
 public function createUser(Form $form, User $user) : bool
 {
     $return = false;
     if (!$this->checkUsername($user->getUsername())) {
         $return = true;
         $form->get('username')->addError(new FormError($this->translator->trans('users.registration.username_already_taken')));
     }
     if (!$this->checkEmail($user->getEmail())) {
         $return = true;
         $form->get('email')->addError(new FormError($this->translator->trans('users.registration.email_already_taken')));
     }
     if ($return) {
         return false;
     }
     $user->setSalt(uniqid('', true));
     $password = $this->encoder->encodePassword($user, $user->getPlainPassword());
     $user->setPassword($password);
     $user->addRole('ROLE_USER');
     $user->enable(false);
     $this->em->persist($user);
     $this->em->flush();
     $this->activationLinkManager->createActivationLink($user);
     $this->activationLinkManager->sendValidationMail($user);
     return true;
 }
开发者ID:Medievistes,项目名称:application,代码行数:30,代码来源:UserManager.php


示例14: Load

 public function Load()
 {
     parent::$PAGE_TITLE = __(ERROR_USER_BANNED) . " - " . __(SITE_NAME);
     parent::$PAGE_META_ROBOTS = "noindex, nofollow";
     $can_use_captacha = true;
     if (WspBannedVisitors::isBannedIp($this->getRemoteIP())) {
         $last_access = new DateTime(WspBannedVisitors::getBannedIpLastAccess($this->getRemoteIP()));
         $duration = WspBannedVisitors::getBannedIpDuration($this->getRemoteIP());
         $dte_ban = $last_access->modify("+" . $duration . " seconds");
         if ($dte_ban > new DateTime()) {
             $can_use_captacha = false;
         }
     }
     $obj_error_msg = new Object(new Picture("wsp/img/warning.png", 48, 48, 0, "absmidlle"), "<br/><br/>");
     $obj_error_msg->add(new Label(__(ERROR_USER_BANNED_MSG_1), true), "<br/>");
     if ($can_use_captacha) {
         $obj_error_msg->add(new Label(__(ERROR_USER_BANNED_MSG_2), true), "<br/><br/>");
         $this->captcha_error_obj = new Object();
         $form = new Form($this);
         $this->captcha = new Captcha($form);
         $this->captcha->setFocus();
         $unblock_btn = new Button($form);
         $unblock_btn->setValue(__(ERROR_USER_BUTTON))->onClick("onClickUnblock");
         $form->setContent(new Object($this->captcha, "<br/>", $unblock_btn));
         $obj_error_msg->add($this->captcha_error_obj, "<br/>", $form);
     }
     $obj_error_msg->add("<br/><br/>", __(MAIN_PAGE_GO_BACK), new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME)));
     $this->render = new ErrorTemplate($obj_error_msg, __(ERROR_USER_BANNED));
 }
开发者ID:kxopa,项目名称:WebSite-PHP,代码行数:29,代码来源:error-user-ban.php


示例15: run

 public function run($static = false)
 {
     $form = new Form();
     $form->post('login')->val('blank')->post('password')->val('blank');
     if (!$form->submit()) {
         // Error
         $this->_error($static);
         return false;
     }
     $data = $form->fetch();
     $login = $data['login'];
     $password = Hash::create('sha256', $data['password'], PASS_HASH_KEY);
     $query = "SELECT userid, login, role FROM user WHERE login = :login AND password = :password";
     if (!($result = $this->db->select($query, array(':login' => $login, ':password' => $password)))) {
         $this->_error($static);
         return false;
     }
     Session::init();
     Session::set('userid', $result[0]['userid']);
     Session::set('login', $result[0]['login']);
     Session::set('role', $result[0]['role']);
     Session::set('loggedIn', true);
     if ($static) {
         header('location:' . URL . 'dashboard');
     }
     echo json_encode('success');
 }
开发者ID:spelgrift,项目名称:imageman,代码行数:27,代码来源:login_model.php


示例16: getContent

 protected function getContent()
 {
     // Prepara formulário de pesquisa
     $dataArr['ajax'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => true]];
     $dataArr['page'] = ["type" => Config::read('form.hidden'), "data" => (object) ["value" => 1]];
     $dataArr['name'] = ["type" => Config::read('form.input'), "data" => (object) ["text" => Text::read('form.product')]];
     $dataArr['btnSearch'] = ["type" => Config::read('form.submit'), "data" => (object) ["text" => Text::read('form.search'), "class" => "primary", "icon" => "glyphicon-search"]];
     $form = new Form("mySearch");
     $form->setHorizontal();
     $searchForm = $form->createForm($dataArr);
     ob_start();
     ?>
         <div class="container">
           <div class="row">
             <a id="toogleFilter" class="pull-right" data-toggle="collapse" data-target="#collapseFilter" href="#">
                 <span class="text">Exibir Filtros </span><span class="glyphicon glyphicon-menu-down"></span>
             </a>
             <div id="collapseFilter" class="panel-body panel-collapse collapse">
                 <?php 
     echo $searchForm;
     ?>
             </div>
           </div>
         </div>
     
         <div id="resultPanel" class="panel-body table-responsive">
             <?php 
     echo $this->result;
     ?>
         </div>
     <?php 
     return ob_get_clean();
 }
开发者ID:sohflp,项目名称:Hooked,代码行数:33,代码来源:class.OrderMyPurchasesView.php


示例17: testIsValid

 /**
  * @covers FormValidatorCustom
  * @covers FormValidator
  */
 public function testIsValid()
 {
     $form = new Form('some template');
     $validationFunction = array($this, 'userValidationFunction');
     // Tests are completely bypassed when the validation type is
     // "optional" and the test field is empty. We make sure this is the
     // case by returning 'false' for the custom validation function.
     $form->setData('testData', '');
     $validator = new FormValidatorCustom($form, 'testData', FORM_VALIDATOR_OPTIONAL_VALUE, 'some.message.key', $validationFunction, array(false));
     self::assertTrue($validator->isValid());
     self::assertSame(null, $this->checkedValue);
     // Simulate valid data
     $form->setData('testData', 'xyz');
     $validator = new FormValidatorCustom($form, 'testData', FORM_VALIDATOR_REQUIRED_VALUE, 'some.message.key', $validationFunction, array(true));
     self::assertTrue($validator->isValid());
     self::assertSame('xyz', $this->checkedValue);
     // Simulate invalid data
     $form->setData('testData', 'xyz');
     $validator = new FormValidatorCustom($form, 'testData', FORM_VALIDATOR_REQUIRED_VALUE, 'some.message.key', $validationFunction, array(false));
     self::assertFalse($validator->isValid());
     self::assertSame('xyz', $this->checkedValue);
     // Simulate valid data with negation of the user function return value
     $form->setData('testData', 'xyz');
     $validator = new FormValidatorCustom($form, 'testData', FORM_VALIDATOR_REQUIRED_VALUE, 'some.message.key', $validationFunction, array(false), true);
     self::assertTrue($validator->isValid());
     self::assertSame('xyz', $this->checkedValue);
 }
开发者ID:anorton,项目名称:pkp-lib,代码行数:31,代码来源:FormValidatorCustomTest.inc.php


示例18: update

 public function update($id)
 {
     $filename = get('filename');
     $page = $this->page($id);
     if (!$page) {
         return response::error(l('files.error.missing.page'));
     }
     $file = $page->file($filename);
     if (!$file) {
         return response::error(l('files.error.missing.file'));
     }
     $blueprint = blueprint::find($page);
     $fields = $blueprint->files()->fields($page);
     // trigger the validation
     $form = new Form($fields->toArray());
     $form->validate();
     // fetch the form data
     $data = filedata::createByInput($file, $form->serialize());
     // stop at invalid fields
     if (!$form->isValid()) {
         return response::error(l('files.show.error.form'), 400, array('fields' => $form->fields()->filterBy('error', true)->pluck('name')));
     }
     try {
         $file->update($data, app::$language);
         return response::success('success', array('data' => $data));
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:29,代码来源:files.php


示例19: info

 /**
  *  Return description of module
  *
  *  @return     string      Texte descripif
  */
 function info()
 {
     global $conf, $langs;
     $langs->load("bills");
     $form = new Form($this->db);
     $texte = $langs->trans('GenericNumRefModelDesc') . "<br>\n";
     $texte .= '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
     $texte .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
     $texte .= '<input type="hidden" name="action" value="updateMask">';
     $texte .= '<input type="hidden" name="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
     $texte .= '<table class="nobordernopadding" width="100%">';
     $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
     $tooltip .= $langs->trans("GenericMaskCodes2");
     $tooltip .= $langs->trans("GenericMaskCodes3");
     $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal"));
     $tooltip .= $langs->trans("GenericMaskCodes5");
     // Parametrage du prefix
     $texte .= '<tr><td>' . $langs->trans("Mask") . ':</td>';
     $texte .= '<td align="right">' . $form->textwithpicto('<input type="text" class="flat" size="24" name="maskpropal" value="' . $conf->global->PROPALE_SAPHIR_MASK . '">', $tooltip, 1, 1) . '</td>';
     $texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button"></td>';
     $texte .= '</tr>';
     $texte .= '</table>';
     $texte .= '</form>';
     return $texte;
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:30,代码来源:mod_propale_saphir.php


示例20: updateImportForm

 function updateImportForm(Form $form)
 {
     /* @var $owner ModelAdmin */
     $owner = $this->owner;
     $class = $owner->modelClass;
     // Overwrite model imports
     $importerClasses = $owner->stat('model_importers');
     if (is_null($importerClasses)) {
         $models = $owner->getManagedModels();
         foreach ($models as $modelName => $options) {
             $importerClasses[$modelName] = 'ExcelBulkLoader';
         }
         $owner->set_stat('model_importers', $importerClasses);
     }
     $modelSNG = singleton($class);
     $modelName = $modelSNG->i18n_singular_name();
     $fields = $form->Fields();
     $content = _t('ModelAdminExcelExtension.DownloadSample', '<div class="field"><a href="{link}">Download sample file</a></div>', array('link' => $owner->Link($class . '/downloadsample')));
     $file = $fields->dataFieldByName('_CsvFile');
     if ($file) {
         $file->setDescription(ExcelImportExport::getValidExtensionsText());
         $file->getValidator()->setAllowedExtensions(ExcelImportExport::getValidExtensions());
     }
     $fields->removeByName("SpecFor{$modelName}");
     $fields->insertAfter('EmptyBeforeImport', new LiteralField("SampleFor{$modelName}", $content));
     if (!$modelSNG->canDelete()) {
         $fields->removeByName('EmptyBeforeImport');
     }
     $actions = $form->Actions();
     $import = $actions->dataFieldByName('action_import');
     if ($import) {
         $import->setTitle(_t('ModelAdminExcelExtension.ImportExcel', "Import from Excel"));
     }
 }
开发者ID:lekoala,项目名称:silverstripe-excel-import-export,代码行数:34,代码来源:ModelAdminExcelExtension.php



注:本文中的Form类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP FormAction类代码示例发布时间:2022-05-23
下一篇:
PHP ForgeConfig类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap