# csActAsAttachablePlugin ##Introduction This behavior permits to attach files to Doctrine objects. ##Features * add/remove attached files on an object / multiple object classes * validate uploaded files * validate according to file type * supports the module csAttachable that allows for ajax includes to upload and add files to a given class Supported filetypes are the following: * image * audio * video * document * application * custom * other The type "other" represents the base filetype, and is not validated by mimetype. Others can be set accordingly. ##Implementation add the following code to your module's schema file: [yml] MyModel: actAs: [Attachable] ##csAttachable module To use csAttachable module, add csAttachable to your settings.yml under "enabled_modules" and add the following code to your template: [php] $form)) ?> where $this->form represents the Doctrine Form for whatever class is acting as attachable. It is important to note the plugin does not work if the passed $this->form does not carry an object already saved to the database. For this reason, the component should not be included unless the form object exists, for example: [php] getObject()->getId()): ?> $form)) ?> Also supported is the csAttachable attachments_list component, which receives an object variable and outputs a UL of attachments and their links. This is handy for frontend development / archive reasons, and also serves as an example for how attachments should be accessed / displayed. Use the following code to access this component: [php] $object)) ?> Where $object is an item acting as Attachable ###Integrating with the backend After completing the steps above, you will want to override the ___form.php__ partial in your backend module. Copy all of the code from the same generated module in your project cache. Then, add the form code above after the tag. At the end, your ___form.php__ partial should look something like this: [php]