Hi there,
Do you need an Image / Photo Field for any module custom or not? I did, and I knocked my head multiple times wondering why the Image Field in the studio did not work! (its in the studio but it has no logic to support it in the detail/editviews) any way...
Happy ending though! .. Here is how I did it - if a real developer stumble upon this: shoot any comment/improvement!
1) Create a new Field of type Image for your desired module
2) Add it to your Detail View / Edit View etc
3) Go to the folder include/SugarFields/Fields/ and download+decompress the 4 files in the zip I posted
4) Try it. There should be a browse link in the EDITVIEW where the field is displayed, and it should display the image in DETAILVIEW.
It works :P - but there are some tricks....
1) EDITVIEW - Remove button needs a change in the controller of the module where you added the field. If you added an image field for the contact module, then you need to change the Contact module controller and add something like this:
PHP Code:
function action_editview(){
$this->view = 'edit';
$GLOBALS['view'] = $this->view;
if(!empty($_REQUEST['deleteAttachment'])){
ob_clean();
$removeFile = clean_path(getAbsolutePath("{$GLOBALS['sugar_config']['upload_dir']}{$this->id}"));
//We should remove the file - i don't do it -- add the logic to delete it below.
echo 'true';
sugar_cleanup(true);
}
}
Be careful, this code does not actually Deleted the file (i did not needed it) add it your self :P
2) You can ONLY add 1 of this FIELD TYPE , current implementation is to NAME THE FILE with the ID of the BEAN. It means that if the contact id is XYZ the file fill be under cache/upload/XYZ . So if you add more than 1 Image Field, both will point to the same pic and be overwriten
it sucks but, I am happy with this 0.1 pre alpha version 
Final notes:
- This image field is an imitation of the File Field from which I based this.
- I use this for the great Advance Open Sales AOS Product Module and it works like a charm
- Tested in 6.3.1 CE with AJAX interface
- It does not upload the file through AJAX, is during the POST - The logic for saving the file is inside the SugarImageField.php
pura vida ~ mrbarletta
Bookmarks