Created
December 5, 2012 15:22
-
-
Save rdohms/4216484 to your computer and use it in GitHub Desktop.
Binding Events in Parent Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class MyAbstractType extends AbstractType | |
{ | |
/** CODE */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyFormType extends MyAbstractType | |
{ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder->add(); | |
... | |
} | |
} |
*extend, not implement
Thanks, that is an idea.
Relying on the getParent still leaves me with the possibility of human error if the dev forgets to do that.
But since this is a service I may be able to do some smart juggling and force this to be called by the app itself.
Will try it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why don't you use the form's native inheritance mechanism? I.e., let both types implement
AbstractType
and definegetParent()
inMyFormType
to return the name ofMyAbstractType
(defined in itsgetName()
). This would solve your problem.