Skip to content

Commit 039ce8a

Browse files
authored
Update Product.php & ProductController.php (#838)
* Update Product.php & ProductController.php move getFormClass() to controller as SS complains: method 'getFormClass' does not exist on 'SilverShop\Page\ProductController' also had to rollback the $this->data()->getFormClass() update to be $this->getFormClass() * Fix linting issues
1 parent c71cda8 commit 039ce8a

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Page/Product.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,4 @@ public function removeAllLink(): string|bool
491491
{
492492
return ShoppingCartController::remove_all_item_link($this);
493493
}
494-
495-
/**
496-
* Get the form class to use to edit this product in the frontend
497-
* @return string FQCN
498-
*/
499-
public function getFormClass(): string
500-
{
501-
$formClass = AddProductForm::class;
502-
$this->extend('updateFormClass', $formClass);
503-
return $formClass;
504-
}
505494
}

src/Page/ProductController.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PageController;
66
use SilverStripe\Core\Injector\Injector;
7+
use SilverShop\Forms\AddProductForm;
78

89
class ProductController extends PageController
910
{
@@ -14,8 +15,19 @@ class ProductController extends PageController
1415

1516
public function Form()
1617
{
17-
$form = Injector::inst()->create($this->data()->getFormClass(), $this, 'Form');
18+
$form = Injector::inst()->create($this->getFormClass(), $this, 'Form');
1819
$this->extend('updateForm', $form);
1920
return $form;
2021
}
22+
23+
/**
24+
* Get the form class to use to edit this product in the frontend
25+
* @return string FQCN
26+
*/
27+
public function getFormClass(): string
28+
{
29+
$formClass = AddProductForm::class;
30+
$this->extend('updateFormClass', $formClass);
31+
return $formClass;
32+
}
2133
}

0 commit comments

Comments
 (0)