• 9
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I have created form with one element from Entity:

$promo = new Promo();

$form = $this->createFormBuilder($promo)
        ->add('code', 'text')
        ->getForm();

And I want to add file element (this field doesn't exist in the Entity). When I do:

$form = $this->createFormBuilder($promo)
        ->add('code', 'text')
        ->add('image', 'file')
        ->getForm();

I have an error: Neither property "image" nor method "getImage()". How can I add this field?

Use mapped:

$form = $this->createFormBuilder($promo)
    ->add('code', 'text')
    ->add('image', 'file', array(
                "mapped" => false,
            ))
    ->getForm();

In old Symfony versions (2.0 and earlier), use property_path:

$form = $this->createFormBuilder($promo)
    ->add('code', 'text')
    ->add('image', 'file', array(
                "property_path" => false,
            ))
    ->getForm();

"property_path" was removed in Symfony 2.3

  • 79
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions