Профил
Loading...
+ Нов въпрос
v.bonapartov avatar v.bonapartov 18 Точки

[Software Technologies] PHP MVC & Symfony - Calculator

Здравейте, колеги,

Опитвам се да направя калкулатора, показан в лекцията от 19 юли.
Получавам следната грешка:
Type error: Too few arguments to function Symfony\Component\Form\FormRenderer::renderBlock().
Някой да се е сблъсквал с подобно нещо?

<?php

namespace AppBundle\Controller;

use AppBundle\Form\CalculatorType;
use AppBundle\Model\Calculator;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class CalculatorController extends Controller
{
    /**
     * @Route("/calculator", name="calculator_index")
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction()
    {
        $form = $this->createForm(CalculatorType::class);

        return $this->render("calculator/index.html.twig",
            [
                'form' => $form->createView()
            ]);
    }
}
<?php

namespace AppBundle\Form;

use AppBundle\Model\Calculator;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CalculatorType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('firstNumber', NumberType::class)
                ->add('secondNumber', NumberType::class);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'data_class' => Calculator::class
            ]
        );
    }

    public function getBlockPrefix()
    {
        return 'app_bundle_calculator_type';
    }
}

Поздрави,
Веселин

 

Тагове:
0
Софтуерни технологии 30/10/2017 10:34:39
RoYaL avatar RoYaL Trainer 6845 Точки

Изтрий кеша на симфонито, ако не стане - махни този метод getBlockPrefix

0
v.bonapartov avatar v.bonapartov 18 Точки

Пробвах и това. Изтрил съм /var/cache и метода getBlockPrefix. Резултата е същия.

<?php

namespace AppBundle\Form;

use AppBundle\Model\Calculator;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CalculatorType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('firstNumber', NumberType::class)
                ->add('secondNumber', NumberType::class)
                ->add('thirdNumber', NumberType::class);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'data_class' => Calculator::class
            ]
        );
    }
}
0