ここに示すように、フォームのコレクションを埋め込もうとしています - http://symfony.com/doc/current/cookbook/form/form_collections.html
そこからほとんどコードを書き直しましたが、2 つの問題に遭遇しました。
FatalErrorException: Compile Error: Declaration of MyBundle\Form\Type\ExpenseType::setDefaultOptions() must be compatible with that of Symfony\Component\Form\FormTypeInterface::setDefaultOptions() in MyBundle\Form\Type\ExpenseType.php line 33
form_start() 関数は存在しません。
最初の問題を解決する方法はありますか? 何も役に立ちません:(
PS本と同じなので、コードを追加していません。名前を変更しただけです(または、少なくともそう思うと思います)。必要に応じてコードを追加します。
ExpenseType.php
<?php
namespace MyBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class ExpenseType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text',array(
'label' => ' '));
$builder->add('description', 'textarea',array(
'label' => ' '));
$builder->add('expenseVariants', 'collection', array('type' => new ExpenseVairantType()));
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'MyBundle\Entity\Expense',
));
}
public function getName()
{
return 'expense';
}
}