I
I
Ivan Antonov2015-10-12 15:15:31
symfony
Ivan Antonov, 2015-10-12 15:15:31

How to change the type to hidden in the form for an entity type field?

There are entities Offer and Image.

class Offer {
    private $image;
    // more properies
}
class Image {
    private $id;
    private $file;

    function __toString() {
        return (string) $this->file;
    }
    // more properies
}

in the form (OfferType) like this:
$builder->add('image');
When building the form for the image field, a select is created with a list of all the photos in the images table. BUT I don't need it. I want to use JS and AJAX to select a photo and add an id to a hidden field.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nonlux, 2015-10-12
@antonowano

symfony.com/doc/current/reference/forms/types/hidd...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question