Custom ajax image upload with crop/resize and form_builder

edited July 2011 in Feature Requests
Hello,
I'd like to be able to upload pictures making use of an ajax-based uploader, and then be able to define crop areas for various size presets (square, rectangular, double square) using something like jcrop or similar.
The thing is, I'd like to add said functionality to an adv. module while still making use of the form_builder's form_fields() definitions - so that the rest of the form would benefit from all the built-in goodness.

So, the question is: what's the best way to achieve this?
I'd be tempted to add a 'custom' type of field to the $fields array with a lot of stuff in its 'after_html' index ... like taking a view and slamming it inside it... with all its JS calls and html - but i have the feeling I'm doing it wrong...
I'm sure I can't be the only one in need of something similar...
Any ideas?
Thanks!!!

Comments

  • edited 3:21PM
    Can you get away with creating the field like normal and adding a css class to it. Then use a custom js file that will take care of initializing the jcrop, etc, functionality for that field?
  • edited 3:21PM
    but then what about the ajax-uploading part? who's gonna validate the ajax upload?
  • edited 3:21PM
    You would need to create a controller to handle that functionality. You could do that by creating an Advanced Module which allows you to create a controller to handle requests like that. Or, you could simply just create a normal controller in the application directory.
    http://www.getfuelcms.com/user_guide/modules/advanced
  • edited 3:21PM
    So i'm of the idea that the best way would be to implement a customised form to handle all this. The best is to go with a controller and let it handle the displaying and submit part of this form.

    So, could you please clarify this :
    If i were to make a controller alongside my models in an advanced module, could i load the models required and use the data table class to display the entries like they are with normal modules in the backend?

    Which view should i take a look at if i wanted to replicate the looks of the entry listing sections of the backend?

    Thanks a lot...
  • edited 3:21PM
    That should work.

    If your controller inherits from the Fuel_base_controller.php, you can use the "_render" method to have your view be displayed within the Admin shell.

    There is a layout and block file that may be of interest located at:
    fuel/modules/fuel/views/_layouts/module_list.php
    fuel/modules/fuel/views/_blocks/module_list_table.php
  • edited 3:21PM
    Ok thanks for the hints. About those blocks, do i need to copy them over to my own module's assets folder or is there a neater way to use them?
  • edited 3:21PM
    You can use the following to load the block from the FUEL module:
    $this->load->module_view(FUEL_FOLDER, '_blocks/module_list', $vars);
Sign In or Register to comment.