Override Form Using Plugin
Hello Team,
I want to add new field in this from class "/vendor/spryker/product-attribute-gui/src/Spryker/Zed/ProductAttributeGui/Communication/Form/AttributeForm.php" using plugin concept.
Tell me the steps how can we achive this?
Comments
-
Hi Ankur,
We have course on how to extend core packages and one form example.
You'd have to extend the form factory at project level and create a new form also at project level which extends the core form template.
Then, the project factory would return an instance of the new form instead of the core one
Spryker would automatically load your project factory instead of the core one if you follow Srpyker's naming conventions for overriding Factories, facades, Config and providers
0 -
Hello @Hidran Arias,
I know this way which is mentioned in the document but We want to try some different way because we want to create our custom module in this module we want to override the same form class in our module using any plugin/dependancy like.
I got one file "/src/Pyz/Zed/Form/FormDependencyProvider.php".But we are trying to check the example of the file but we are not able to get any suitable example.
Any help would be appriciated!0 -
I took a look at the ProductAttributeFormGui but there isn't any plugin you can hook into for that form.
The form is created in the factory:
public function createAttributeForm(array $data = [], array $options = [])
{
return $this->getFormFactory()->create(AttributeForm::class, $data, $options);
}
So, they only way to add a new field would be to override that factory method at project level, extend that form and add the new field. This has to be created with the same module's name otherwise it won't be auto discoverable.
1
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 69 Spryker News
- 896 Developer Corner
- 758 Spryker Development
- 83 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 23 Job Opportunities
- 3.2K ๐ Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random