File-Upload-Form ================ Single File-Form ---------------- Add File-Upload in „foreign“ Entities: **A. Define the Entity-Connection** .. code-block:: php /** * @ORM\OneToOne(targetEntity="tpoint\FileBundle\Entity\File", cascade={"persist"}, orphanRemoval=true) * @ORM\JoinColumn(name="file_id", referencedColumnName="id", nullable=false) */ private $file; **B. Add Method to Entity** ``setFile(File $file = null)`` **C. Add Form-Field to FormType** .. code-block:: php use tpoint\FileBundle\Form\EventListener\FileFieldSubscriber; ... $builder->addEventSubscriber(new FileFieldSubscriber()); **D. Add the JS-Formatting to the Template** (http://www.jasny.net/bootstrap/javascript/#fileinput) .. code-block:: html The Source-Files (js+css) are not required, if you use the default-config for tpoint-standard (e.g. with grunt and minify/uglify). **E. Show the File-Link in the Form, if there is a Document** This ist checked via "required", because the field must not be empty, when there isn't a file uploaded .. code-block:: php {% if form.file.vars.required == false %}
{{ entity.file.label }}
{% endif %} Multiple-Upload Action ---------------------- TODO!!