当前位置: 首页>>代码示例>>PHP>>正文


PHP GridField_FormAction::setAttribute方法代码示例

本文整理汇总了PHP中GridField_FormAction::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField_FormAction::setAttribute方法的具体用法?PHP GridField_FormAction::setAttribute怎么用?PHP GridField_FormAction::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GridField_FormAction的用法示例。


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

示例1: getHTMLFragments

 /**
  * Returns a map where the keys are fragment names and the values are
  * pieces of HTML to add to these fragments.
  *
  * Here are 4 built-in fragments: 'header', 'footer', 'before', and
  * 'after', but components may also specify fragments of their own.
  *
  * To specify a new fragment, specify a new fragment by including the
  * text "$DefineFragment(fragmentname)" in the HTML that you return.
  *
  * Fragment names should only contain alphanumerics, -, and _.
  *
  * If you attempt to return HTML for a fragment that doesn't exist, an
  * exception will be thrown when the {@link GridField} is rendered.
  *
  * @param GridField $gridField
  * @return array
  */
 public function getHTMLFragments($gridField)
 {
     $button = new GridField_FormAction($gridField, $this->actionName, $this->buttonText, $this->actionName, null);
     $button->addExtraClass('multiselect-button');
     if (!empty($this->buttonConfig['icon'])) {
         $button->setAttribute('data-icon', $this->buttonConfig['icon']);
     }
     if (!empty($this->buttonConfig['class'])) {
         $button->addExtraClass($this->buttonConfig['class']);
     }
     if (!empty($this->buttonConfig['confirm'])) {
         $button->setAttribute('data-confirm', $this->buttonConfig['confirm']);
     }
     return array($this->targetFragment => $button->Field());
 }
开发者ID:markguinn,项目名称:silverstripe-gridfieldmultiselect,代码行数:33,代码来源:GridFieldApplyToMultipleRows.php

示例2: getHTMLFragments

 public function getHTMLFragments($gridField)
 {
     $button = new GridField_FormAction($gridField, 'syncwithyoutube', _t('GridFieldSyncYoutubeVideos.CTA', 'Sync with Youtube'), 'syncwithyoutube', null);
     $button->setAttribute('data-icon', 'accept');
     $button->addExtraClass('no-ajax');
     return array($this->targetFragment => '<p class="grid-csv-button">' . $button->Field() . '<br><br></p>');
 }
开发者ID:helpfulrobot,项目名称:level51-silverstripe-youtubesync,代码行数:7,代码来源:GridFieldSyncYoutubeVideos.php

示例3: getHTMLFragments

 /**
  * Place the export button in a <p> tag below the field
  */
 public function getHTMLFragments($gridField)
 {
     $button = new GridField_FormAction($gridField, 'export', _t('TableListField.CSVEXPORT', 'Export to CSV'), 'export', null);
     $button->setAttribute('data-icon', 'download-csv');
     $button->addExtraClass('no-ajax');
     return array($this->targetFragment => '<p class="grid-csv-button">' . $button->Field() . '</p>');
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:10,代码来源:GridFieldExportButton.php

示例4: getHTMLFragments

 /**
  * 
  * @param GridField $gridField
  * @return string - HTML
  */
 public function getHTMLFragments($gridField)
 {
     $searchState = $gridField->State->GridFieldSearchRelation;
     $dataClass = $gridField->getList()->dataClass();
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     $value = $this->findSingleEntry($gridField, $searchFields, $searchState, $dataClass);
     $searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"), $value);
     // Apparently the data-* needs to be double qouted for the jQuery.meta data plugin
     $searchField->setAttribute('data-search-url', '\'' . Controller::join_links($gridField->Link('search') . '\''));
     $searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
     $searchField->addExtraClass('relation-search no-change-track');
     $findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
     $findAction->setAttribute('data-icon', 'relationfind');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     // If an object is not found, disable the action
     if (!is_int($gridField->State->GridFieldAddRelation)) {
         $addAction->setReadonly(true);
     }
     $forTemplate->Fields->push($searchField);
     $forTemplate->Fields->push($findAction);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
 }
开发者ID:normann,项目名称:sapphire,代码行数:31,代码来源:GridFieldAddExistingAutocompleter.php

示例5: getHTMLFragments

 /**
  * Place the print button in a <p> tag below the field
  *
  * @param GridField
  *
  * @return array
  */
 public function getHTMLFragments($gridField)
 {
     $button = new GridField_FormAction($gridField, 'print', _t('TableListField.Print', 'Print'), 'print', null);
     $button->setAttribute('data-icon', 'grid_print');
     $button->addExtraClass('gridfield-button-print');
     return array($this->targetFragment => '<p class="grid-print-button">' . $button->Field() . '</p>');
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:14,代码来源:GridFieldPrintButton.php

示例6: getHTMLFragments

 public function getHTMLFragments($gridField)
 {
     $model = Injector::inst()->create($gridField->getModelClass());
     $parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
     if (!$model->canCreate()) {
         return array();
     }
     $children = $this->getAllowedChildren($parent);
     if (count($children) > 1) {
         $pageTypes = DropdownField::create("PageType", "Page Type", $children, $model->defaultChild());
         $pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
         }
     } else {
         $keys = array_keys($children);
         $pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
         }
     }
     $state = $gridField->State->GridFieldSiteTreeAddNewButton;
     $state->currentPageID = $parent->ID;
     $state->pageType = $parent->defaultChild();
     $addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
     $addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($pageTypes);
     $forTemplate->Fields->push($addAction);
     Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
     Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
     return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
 }
开发者ID:micmania1,项目名称:silverstripe-lumberjack,代码行数:34,代码来源:GridFieldSiteTreeAddNewButton.php

示例7: getHTMLFragments

 /**
  * Place the export button in a <p> tag below the field
  */
 public function getHTMLFragments($gridField)
 {
     $btnLabel = _t('Hail', 'Fetch {type}', ['type' => singleton($gridField->getModelClass())->i18n_plural_name()]);
     $button = new GridField_FormAction($gridField, 'fetchhail', $btnLabel, 'fetchhail', null);
     $button->setAttribute('data-icon', 'fetchHail');
     // $button->addExtraClass('ss-ui-action-constructive');
     return array($this->targetFragment => $button->Field());
 }
开发者ID:firebrandhq,项目名称:silverstripe-hail,代码行数:11,代码来源:GridFieldHailFetchButton.php

示例8: getHTMLFragments

 /**
  * Get the html/css button and upload field to perform import.
  */
 public function getHTMLFragments($gridField)
 {
     $button = new GridField_FormAction($gridField, 'import', _t('TableListField.CSVIMPORT', 'Import from CSV'), 'import', null);
     $button->setAttribute('data-icon', 'drive-upload');
     $button->addExtraClass('no-ajax');
     $uploadfield = $this->getUploadField($gridField);
     $data = array('Button' => $button, 'UploadField' => $uploadfield);
     $importerHTML = ArrayData::create($data)->renderWith("GridFieldImporter");
     Requirements::javascript('importexport/javascript/GridFieldImporter.js');
     return array($this->targetFragment => $importerHTML);
 }
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-importexport,代码行数:14,代码来源:GridFieldImporter.php

示例9: getHTMLFragments

 public function getHTMLFragments($gridField)
 {
     Requirements::css(FindManyManyDropdown_PATH . '/css/FindManyManyDropdown.css');
     Requirements::javascript(FindManyManyDropdown_PATH . '/javascript/FindManyManyDropdownForm.js');
     $targetFragment = 'before';
     if ($gridField->getConfig()->getComponentByType('GridFieldButtonRow')) {
         $targetFragment = 'buttons-before-right';
     }
     $dataClass = $gridField->list->dataClass;
     $dropdownOptions = new DropdownField('gridfield_relationdropdown', 'Please choose an object', Dataobject::get($dataClass)->map("ID", "Title"));
     $dropdownOptions->setEmptyString('Select:');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addDDto', 'addDDto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($dropdownOptions);
     $forTemplate->Fields->push($addAction);
     return array($targetFragment => $forTemplate->renderWith('FindManyManyDropdownForm'));
 }
开发者ID:helpfulrobot,项目名称:jonshutt-find-many-many-dropdown,代码行数:19,代码来源:FindManyManyDropdown.php

示例10: getHTMLFragments

 public function getHTMLFragments($gridField)
 {
     $button = new GridField_FormAction($gridField, 'defaultEventTypes', 'Add Default Event Types', 'addDefaultEventTypes', null);
     $button->setAttribute('data-icon', 'chain--plus');
     return array($this->targetFragment => $button->Field());
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:6,代码来源:GridFieldAddDefaultEventTypes.php

示例11: getHTMLFragments

 /**
  * Adds the form fields for the batch actions
  * 
  * @param GridField $gridField GridField to get HTML fragments for
  * 
  * @return array
  */
 public function getHTMLFragments($gridField)
 {
     Requirements::css('silvercart/admin/css/SilvercartGridFieldBatchController.css');
     Requirements::javascript('silvercart/admin/javascript/SilvercartGridFieldBatchController.js');
     $source = array('' => 'Bitte wählen');
     $targetBatchActionObjects = $this->getTargetBatchActionObjects();
     foreach ($targetBatchActionObjects as $targetBatchAction => $targetBatchActionObject) {
         $source[$targetBatchAction] = $targetBatchActionObject->getTitle();
         $targetBatchActionObject->RequireJavascript();
     }
     $dropdown = new DropdownField($this->getDropdownName(), $this->getDropdownName(), $source);
     $dropdown->addExtraClass('grid-batch-action-selector');
     $button = new GridField_FormAction($gridField, 'execute_batch_action', _t('Silvercart.EXECUTE', 'Execute'), 'handleBatchAction', null);
     $button->setAttribute('data-icon', 'navigation');
     $button->addExtraClass('gridfield-button-batch');
     return array($this->targetFragment => '<div class="grid-batch-action-button"><div class="field dropdown plain">' . $dropdown->Field() . '</div><div class="grid-batch-action-callback-target"></div>' . $button->Field() . '</div>');
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:24,代码来源:SilvercartGridFieldBatchController.php

示例12: getHTMLFragments

 /**
  * Renders the TextField and add button to the GridField.
  *
  * @param $girdField GridField
  *
  * @return string HTML
  **/
 public function getHTMLFragments($gridField)
 {
     $dataClass = $gridField->getList()->dataClass();
     $obj = singleton($dataClass);
     if (!$obj->canCreate()) {
         return "";
     }
     $dbField = $this->getDataObjectField();
     $textField = TextField::create("gridfieldaddbydbfield[" . $obj->ClassName . "][" . Convert::raw2htmlatt($dbField) . "]")->setAttribute("placeholder", $obj->fieldLabel($dbField))->addExtraClass("no-change-track");
     $addAction = new GridField_FormAction($gridField, 'add', _t('GridFieldAddByDBField.Add', "Add {name}", "Add button text", array("name" => $obj->i18n_singular_name())), 'add', 'add');
     $addAction->setAttribute('data-icon', 'add');
     // Start thinking about rending this back to the GF
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($textField);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith("GridFieldAddByDBField"));
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-filterablearchive,代码行数:25,代码来源:GridFieldAddByDBField.php

示例13: getHTMLFragments

 /**
  * Renders the TextField and add button to the GridField.
  *
  * @param $gridField GridField
  *
  * @return string
  */
 public function getHTMLFragments($gridField)
 {
     /**
      * @var DataList $dataList
      */
     $dataList = $gridField->getList();
     $dataClass = $dataList->dataClass();
     $obj = singleton($dataClass);
     if (!$obj->canCreate()) {
         return "";
     }
     $dbField = $this->getDataObjectField();
     $textField = TextField::create(sprintf("gridfieldaddbydbfield[%s][%s]", $obj->ClassName, Convert::raw2htmlatt($dbField)))->setAttribute('placeholder', $obj->fieldLabel($dbField))->addExtraClass('no-change-track');
     $addAction = new GridField_FormAction($gridField, 'add', _t('GridFieldAddByDBField.Add', 'Add {name}', "Add button text", array('name' => $obj->i18n_singular_name())), 'add', 'add');
     $addAction->setAttribute('data-icon', 'add');
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($textField);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith('GridFieldAddByDBField'));
 }
开发者ID:sunnysideup,项目名称:silverstripe-blog,代码行数:28,代码来源:GridFieldAddByDBField.php

示例14: getHTMLFragments

 /**
  *
  * @param GridField $gridField
  * @return string - HTML
  */
 public function getHTMLFragments($gridField)
 {
     $dataClass = $gridField->getList()->dataClass();
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"));
     $searchField->setAttribute('data-search-url', Controller::join_links($gridField->Link('search')));
     $searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
     $searchField->addExtraClass('relation-search no-change-track');
     $findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
     $findAction->setAttribute('data-icon', 'relationfind');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     // If an object is not found, disable the action
     if (!is_int($gridField->State->GridFieldAddRelation(null))) {
         $addAction->setReadonly(true);
     }
     $forTemplate->Fields->push($searchField);
     $forTemplate->Fields->push($findAction);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:27,代码来源:GridFieldAddExistingAutocompleter.php

示例15: getHTMLFragments

 /**
  * Renders the TextField and add button to the GridField.
  *
  * @param $girdField GridField
  *
  * @return string HTML
  **/
 public function getHTMLFragments($gridField)
 {
     $dataClass = $gridField->getList()->dataClass();
     $obj = singleton($dataClass);
     if (!$obj->canCreate()) {
         return "";
     }
     $dbField = $this->getDataObjectField();
     $textField = TextField::create("gridfieldaddbydbfield")->setAttribute("placeholder", _t("GridFieldAddOrderItem.Add", "Add by {Filters} or {Title}", array("Filters" => implode(",", $this->getFilterFields()), "Title" => $this->getCreateField())))->addExtraClass("relation-search no-change-track")->setAttribute('data-search-url', Controller::join_links($gridField->Link('search')));
     $addAction = new GridField_FormAction($gridField, 'gridfield_orderitemadd', _t("GridFieldAddOrderItem.Add", "Add"), 'add', 'add');
     $addAction->setAttribute('data-icon', 'add');
     // Start thinking about rending this back to the GF
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($textField);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith("GridFieldAddOrderItem"));
 }
开发者ID:i-lateral,项目名称:silverstripe-orders,代码行数:25,代码来源:GridFieldAddOrderItem.php


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