Created
May 24, 2016 12:23
-
-
Save mhlavac/0c2ba5ca5c7e95e5e7d83d7c36164405 to your computer and use it in GitHub Desktop.
Symfony2 inherit_data issues and workaround
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 NameType extends \Symfony\Component\Form\AbstractType | |
{ | |
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) | |
{ | |
$builder->add('firstName', 'text'); | |
$builder->add('lastName', 'text'); | |
} | |
} |
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 Person | |
{ | |
public $firstName; | |
public $lastName; | |
public $age; | |
} |
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 PersonType extends \Symfony\Component\Form\AbstractType | |
{ | |
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) | |
{ | |
$builder->add('name', NameType::class, ['inherit_data' => true]); | |
$builder->add('age', 'integer'); | |
} | |
} |
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 User | |
{ | |
public $firstName; | |
public $lastName; | |
public $email; | |
} |
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 PersonType extends \Symfony\Component\Form\AbstractType | |
{ | |
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) | |
{ | |
$builder->add('name', NameType::class, ['inherit_data' => true]); | |
$builder->add('email', 'email'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment