我和实体A将oneToMany与实体B联系起来.我希望用户可以选择从现有的B实体中选择或者在A类的形式上创建一个新的实体.到目前为止,我在我的表单上有这个:
->add('ExistingB', 'entity', array(
'class' => 'AppBundle\Entity\B',
'required' => false,
'property_path' => 'B',
'mapped' => false,
))
->add('newB', new BType(), array(
'required' => false,
'property_path' => 'B',
'mapped' => false,
));
$builder->addEventListener(
FormEvents::POST_SUBMIT , function (FormEvent $event) {
$formB= $event->getForm()->get('newB');
if ($formB->get('name')->getData() != null){
//here i need to somehow say to the form that it needs to set mapped true
//to the formB field so it can create a new entity and update the relationship
}else{
//here I need to …Run Code Online (Sandbox Code Playgroud) 对不起,我是重复的,但我似乎没有找到我需要澄清的确切方案.
所以我的问题是为什么:
var = array ();
echo count (var);
Run Code Online (Sandbox Code Playgroud)
打印0.
还有这个:
var = array (array());
echo count (var);
Run Code Online (Sandbox Code Playgroud)
打印1?
谢谢!