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


PHP GridFieldConfig::addComponent方法代码示例

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


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

示例1: __construct

 public function __construct($controller, $name, $show_actions = true)
 {
     $TempBasketID = Store_BasketController::get_temp_basket_id();
     $order_id = DB::Query("SELECT id FROM `order` WHERE (`TempBasketID`='" . $TempBasketID . "')")->value();
     /* Basket GridField */
     $config = new GridFieldConfig();
     $dataColumns = new GridFieldDataColumns();
     $dataColumns->setDisplayFields(array('getPhoto' => "Photo", 'Title' => 'Product', 'Price' => 'Item Price', 'Quantity' => 'Quantity', 'productPrice' => 'Total Price', 'getfriendlyTaxCalculation' => 'Tax Inc/Exc', 'TaxClassName' => 'Tax'));
     $config->addComponent($dataColumns);
     $config->addComponent(new GridFieldTitleHeader());
     $basket = GridField::create("BasketItems", "", DataObject::get("Order_Items", "(OrderID='" . $order_id . "')"), $config);
     /* Basket Subtotal */
     $subtotal = new Order();
     $subtotal = $subtotal->calculateSubTotal($order_id);
     $subtotal = ReadonlyField::create("SubTotal", "Basket Total (" . Product::getDefaultCurrency() . ")", $subtotal);
     /* Fields */
     $fields = FieldList::create($basket, $subtotal, ReadonlyField::create("Tax", "Tax", "Calculated on the Order Summary page."));
     /* Actions */
     $actions = FieldList::create(CompositeField::create(FormAction::create('continueshopping', 'Continue Shopping'), FormAction::create('placeorder', 'Place Order')));
     /* Required Fields */
     $required = new RequiredFields(array());
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $show_actions ? $actions : FieldList::create(), $required);
 }
开发者ID:micschk,项目名称:torindul-silverstripe-shop,代码行数:27,代码来源:BasketForm.php

示例2: __construct

 /**
  * Creates a new GridField field
  *
  * @param string $name
  * @param string $title
  * @param SS_List $dataList
  * @param GridFieldConfig $config
  */
 public function __construct($name, $title = null, SS_List $dataList = null, GridFieldConfig $config = null)
 {
     parent::__construct($name, $title, null);
     $this->name = $name;
     if ($dataList) {
         $this->setList($dataList);
     }
     $this->setConfig($config ?: GridFieldConfig_Base::create());
     $this->config->addComponent(new GridState_Component());
     $this->state = new GridState($this);
     $this->addExtraClass('ss-gridfield');
 }
开发者ID:normann,项目名称:sapphire,代码行数:20,代码来源:GridField.php

示例3: getCMSFields

 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Values');
     $values = new GridField("Values", "SubmittedFormField", $this->Values()->sort('Created', 'ASC'));
     $config = new GridFieldConfig();
     $config->addComponent(new GridFieldDataColumns());
     $config->addComponent(new GridFieldExportButton());
     $config->addComponent(new GridFieldPrintButton());
     $values->setConfig($config);
     $fields->addFieldToTab('Root.Main', $values);
     return $fields;
 }
开发者ID:vinstah,项目名称:body,代码行数:16,代码来源:SubmittedForm.php

示例4: getCMSFields

 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $fields->removeByName('Values');
         $fields->dataFieldByName('SubmittedByID')->setDisabled(true);
         $values = new GridField('Values', 'SubmittedFormField', $self->Values()->sort('Created', 'ASC'));
         $config = new GridFieldConfig();
         $config->addComponent(new GridFieldDataColumns());
         $config->addComponent(new GridFieldExportButton());
         $config->addComponent(new GridFieldPrintButton());
         $values->setConfig($config);
         $fields->addFieldToTab('Root.Main', $values);
     });
     $fields = parent::getCMSFields();
     return $fields;
 }
开发者ID:camfindlay,项目名称:silverstripe-userforms,代码行数:20,代码来源:SubmittedForm.php

示例5: testChainedDataManipulators

 public function testChainedDataManipulators()
 {
     $config = new GridFieldConfig();
     $data = new ArrayList(array(1, 2, 3, 4, 5, 6));
     $gridField = new GridField('testfield', 'testfield', $data, $config);
     $endList = $gridField->getManipulatedList();
     $this->assertEquals($endList->Count(), 6);
     $config->addComponent(new GridFieldTest_Component2());
     $endList = $gridField->getManipulatedList();
     $this->assertEquals($endList->Count(), 12);
     $config->addComponent(new GridFieldPaginator(10));
     $endList = $gridField->getManipulatedList();
     $this->assertEquals($endList->Count(), 10);
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:14,代码来源:GridFieldTest.php

示例6: getCMSFields

    /**
     * @return FieldList
     */
    public function getCMSFields()
    {
        $self = $this;
        $this->beforeUpdateCMSFields(function ($fields) use($self) {
            // define tabs
            $fields->findOrMakeTab('Root.FormContent', _t('UserDefinedForm.FORM', 'Form'));
            $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
            $fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients'));
            $fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
            // field editor
            $fields->addFieldToTab('Root.FormContent', new FieldEditor('Fields', 'Fields', '', $self));
            // text to show on complete
            $onCompleteFieldSet = new CompositeField($label = new LabelField('OnCompleteMessageLabel', _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')), $editor = new HtmlEditorField('OnCompleteMessage', '', _t('UserDefinedForm.ONCOMPLETEMESSAGE', $self->OnCompleteMessage)));
            $onCompleteFieldSet->addExtraClass('field');
            $editor->setRows(3);
            $label->addExtraClass('left');
            // Define config for email recipients
            $emailRecipientsConfig = GridFieldConfig_RecordEditor::create(10);
            $emailRecipientsConfig->getComponentByType('GridFieldAddNewButton')->setButtonName(_t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient'));
            // who do we email on submission
            $emailRecipients = new GridField('EmailRecipients', _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $self->EmailRecipients(), $emailRecipientsConfig);
            $emailRecipients->getConfig()->getComponentByType('GridFieldDetailForm')->setItemRequestClass('UserDefinedForm_EmailRecipient_ItemRequest');
            $fields->addFieldsToTab('Root.FormOptions', $onCompleteFieldSet);
            $fields->addFieldToTab('Root.Recipients', $emailRecipients);
            $fields->addFieldsToTab('Root.FormOptions', $self->getFormOptions());
            // view the submissions
            $submissions = new GridField('Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), $self->Submissions()->sort('Created', 'DESC'));
            // make sure a numeric not a empty string is checked against this int column for SQL server
            $parentID = !empty($self->ID) ? $self->ID : 0;
            // get a list of all field names and values used for print and export CSV views of the GridField below.
            $columnSQL = <<<SQL
SELECT "Name", "Title"
FROM "SubmittedFormField"
LEFT JOIN "SubmittedForm" ON "SubmittedForm"."ID" = "SubmittedFormField"."ParentID"
WHERE "SubmittedForm"."ParentID" = '{$parentID}'
ORDER BY "Title" ASC
SQL;
            $columns = DB::query($columnSQL)->map();
            $config = new GridFieldConfig();
            $config->addComponent(new GridFieldToolbarHeader());
            $config->addComponent($sort = new GridFieldSortableHeader());
            $config->addComponent($filter = new UserFormsGridFieldFilterHeader());
            $config->addComponent(new GridFieldDataColumns());
            $config->addComponent(new GridFieldEditButton());
            $config->addComponent(new GridState_Component());
            $config->addComponent(new GridFieldDeleteAction());
            $config->addComponent(new GridFieldPageCount('toolbar-header-right'));
            $config->addComponent($pagination = new GridFieldPaginator(25));
            $config->addComponent(new GridFieldDetailForm());
            $config->addComponent($export = new GridFieldExportButton());
            $config->addComponent($print = new GridFieldPrintButton());
            /**
             * Support for {@link https://github.com/colymba/GridFieldBulkEditingTools}
             */
            if (class_exists('GridFieldBulkManager')) {
                $config->addComponent(new GridFieldBulkManager());
            }
            $sort->setThrowExceptionOnBadDataType(false);
            $filter->setThrowExceptionOnBadDataType(false);
            $pagination->setThrowExceptionOnBadDataType(false);
            // attach every column to the print view form
            $columns['Created'] = 'Created';
            $filter->setColumns($columns);
            // print configuration
            $print->setPrintHasHeader(true);
            $print->setPrintColumns($columns);
            // export configuration
            $export->setCsvHasHeader(true);
            $export->setExportColumns($columns);
            $submissions->setConfig($config);
            $fields->addFieldToTab('Root.Submissions', $submissions);
            $fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')));
        });
        $fields = parent::getCMSFields();
        return $fields;
    }
开发者ID:sekjal,项目名称:silverstripe-userforms,代码行数:79,代码来源:UserDefinedForm.php

示例7: getCMSFields

    /**
     * @return FieldList
     */
    public function getCMSFields()
    {
        // call updateCMSFields after userforms
        SiteTree::disableCMSFieldsExtensions();
        $fields = parent::getCMSFields();
        SiteTree::enableCMSFieldsExtensions();
        // define tabs
        $fields->findOrMakeTab('Root.FormContent', _t('UserDefinedForm.FORM', 'Form'));
        $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
        $fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
        // field editor
        $fields->addFieldToTab("Root.FormContent", new FieldEditor("Fields", 'Fields', "", $this));
        // text to show on complete
        $onCompleteFieldSet = new CompositeField($label = new LabelField('OnCompleteMessageLabel', _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion')), $editor = new HtmlEditorField("OnCompleteMessage", "", _t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage)));
        $onCompleteFieldSet->addExtraClass('field');
        $editor->setRows(3);
        $label->addExtraClass('left');
        // Set the summary fields of UserDefinedForm_EmailRecipient dynamically via config system
        Config::inst()->update('UserDefinedForm_EmailRecipient', 'summary_fields', array('EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'), 'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'), 'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From')));
        // who do we email on submission
        $emailRecipients = new GridField("EmailRecipients", _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10));
        $emailRecipients->getConfig()->getComponentByType('GridFieldAddNewButton')->setButtonName(_t('UserDefinedForm.ADDEMAILRECIPIENT', 'Add Email Recipient'));
        $fields->addFieldsToTab("Root.FormOptions", $onCompleteFieldSet);
        $fields->addFieldToTab("Root.FormOptions", $emailRecipients);
        $fields->addFieldsToTab("Root.FormOptions", $this->getFormOptions());
        // view the submissions
        $submissions = new GridField("Reports", _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), $this->Submissions()->sort('Created', 'DESC'));
        // make sure a numeric not a empty string is checked against this int column for SQL server
        $parentID = !empty($this->ID) ? $this->ID : 0;
        // get a list of all field names and values used for print and export CSV views of the GridField below.
        $columnSQL = <<<SQL
SELECT "Name", "Title"
FROM "SubmittedFormField"
LEFT JOIN "SubmittedForm" ON "SubmittedForm"."ID" = "SubmittedFormField"."ParentID"
WHERE "SubmittedForm"."ParentID" = '{$parentID}'
ORDER BY "Title" ASC
SQL;
        $columns = DB::query($columnSQL)->map();
        $config = new GridFieldConfig();
        $config->addComponent(new GridFieldToolbarHeader());
        $config->addComponent($sort = new GridFieldSortableHeader());
        $config->addComponent($filter = new UserFormsGridFieldFilterHeader());
        $config->addComponent(new GridFieldDataColumns());
        $config->addComponent(new GridFieldEditButton());
        $config->addComponent(new GridState_Component());
        $config->addComponent(new GridFieldDeleteAction());
        $config->addComponent(new GridFieldPageCount('toolbar-header-right'));
        $config->addComponent($pagination = new GridFieldPaginator(25));
        $config->addComponent(new GridFieldDetailForm());
        $config->addComponent($export = new GridFieldExportButton());
        $config->addComponent($print = new GridFieldPrintButton());
        $sort->setThrowExceptionOnBadDataType(false);
        $filter->setThrowExceptionOnBadDataType(false);
        $pagination->setThrowExceptionOnBadDataType(false);
        // attach every column to the print view form
        $columns['Created'] = 'Created';
        $filter->setColumns($columns);
        // print configuration
        $print->setPrintHasHeader(true);
        $print->setPrintColumns($columns);
        // export configuration
        $export->setCsvHasHeader(true);
        $export->setExportColumns($columns);
        $submissions->setConfig($config);
        $fields->addFieldToTab("Root.Submissions", $submissions);
        $fields->addFieldToTab("Root.FormOptions", new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', "Disable Saving Submissions to Server")));
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
开发者ID:prostart,项目名称:erics-homes,代码行数:72,代码来源:UserDefinedForm.php

示例8: testCanViewOnlyOddIDs

 /**
  *  @covers GridField::FieldHolder
  */
 public function testCanViewOnlyOddIDs()
 {
     $this->logInWithPermission();
     $list = new ArrayList(array(new GridFieldTest_Permissions(array("ID" => 1, "Email" => "ongi.schwimmer@example.org", 'Name' => 'Ongi Schwimmer')), new GridFieldTest_Permissions(array("ID" => 2, "Email" => "klaus.lozenge@example.org", 'Name' => 'Klaus Lozenge')), new GridFieldTest_Permissions(array("ID" => 3, "Email" => "otto.fischer@example.org", 'Name' => 'Otto Fischer'))));
     $config = new GridFieldConfig();
     $config->addComponent(new GridFieldDataColumns());
     $obj = new GridField('testfield', 'testfield', $list, $config);
     $form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList());
     $content = new CSSContentParser($obj->FieldHolder());
     $members = $content->getBySelector('.ss-gridfield-item tr');
     $this->assertEquals(2, count($members));
     $this->assertEquals((string) $members[0]->td[0], 'Ongi Schwimmer', 'First object Name should be Ongi Schwimmer');
     $this->assertEquals((string) $members[0]->td[1], 'ongi.schwimmer@example.org', 'First object Email should be ongi.schwimmer@example.org');
     $this->assertEquals((string) $members[1]->td[0], 'Otto Fischer', 'Second object Name should be Otto Fischer');
     $this->assertEquals((string) $members[1]->td[1], 'otto.fischer@example.org', 'Second object Email should be otto.fischer@example.org');
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:19,代码来源:GridFieldTest.php


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