liqiusheng / silverstripe-ecommerce

Automatically exported from code.google.com/p/silverstripe-ecommerce
0 stars 0 forks source link

EcommerceCountry (Delete problem in CMS) #455

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
eCommerce version affected: 1.0 r3149
SilverStripe version: 2.4.7
Browser/Operating System used: Firefox 14.0.1

It is important that you are in debug mode.
To do this make sure that in mysite/_config.php is the following line:
Director::set_environment_type('dev');

What steps will reproduce the problem?
1. In CMS click Shop option menu
2. Select Country
3. Click Search button
4. Click Create Country button
5. In the field Name enter a text, for example: aa
6. Click Add button
7. Click Delete button

A problem occurs with the function array_fill in line 743 of ModelAdmin.php
The deletion occurs, but the CMS is blocked and does not show the table of 
countries.

Regards,
Jose

Original issue reported on code.google.com by supp...@sendasoft.com on 10 Aug 2012 at 2:16

GoogleCodeExporter commented 8 years ago
I can confirm this error. But I think it is a modeladmin rather than an 
e-commerce error. 

Original comment by nfranc...@gmail.com on 9 Sep 2012 at 1:37

GoogleCodeExporter commented 8 years ago
Yes, From what I see getResultsTable function (ModelAdmin.php - Line 743) has a 
problem.

The line 
        $tf->setFieldFormatting(array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url)));

should be replaced by
------------
        $countsummaryfields = count($summaryFields);
        if ($countsummaryfields > 0)
            $aa = array_combine(array_keys($summaryFields), array_fill(0,$countsummaryfields, $url));
        else
            $aa = array();
       $tf->setFieldFormatting($aa);
------------
********** Now, the function should look like *************
------------
/**
     * Creates and returns the result table field for resultsForm.
     * Uses {@link resultsTableClassName()} to initialise the formfield. 
     * Method is called from {@link ResultsForm}.
     *
     * @param array $searchCriteria passed through from ResultsForm 
     *
     * @return TableListField 
     */
    function getResultsTable($searchCriteria) {

        $summaryFields = $this->getResultColumns($searchCriteria);

        $className = $this->parentController->resultsTableClassName();
        $tf = new $className(
            $this->modelClass,
            $this->modelClass,
            $summaryFields
        );

        $tf->setCustomQuery($this->getSearchQuery($searchCriteria));
        $tf->setPageSize($this->parentController->stat('page_length'));
        $tf->setShowPagination(true);
        // @todo Remove records that can't be viewed by the current user
        $tf->setPermissions(array_merge(array('view','export'), TableListField::permissions_for_object($this->modelClass)));

        // csv export settings (select all columns regardless of user checkbox settings in 'ResultsAssembly')
        $exportFields = $this->getResultColumns($searchCriteria, false);
        $tf->setFieldListCsv($exportFields);

        $url = '<a href=\"' . $this->Link() . '/$ID/edit\">$value</a>';

        $countsummaryfields = count($summaryFields);
        if ($countsummaryfields > 0)
            $aa = array_combine(array_keys($summaryFields), array_fill(0,$countsummaryfields, $url));
        else
            $aa = array();
       $tf->setFieldFormatting($aa);

        // Linea original de SilverStripe
        //$tf->setFieldFormatting(array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url)));

        return $tf;
    }

Regards Nicolaas!

Jose

Original comment by supp...@sendasoft.com on 13 Nov 2012 at 10:28