Add custom action for 'simple' module.

edited February 2015 in News & Announcements
Hello Admin,
I need help in customizing "simple" module.
I've created module for admin part by editing MY_fuel_modules.php. In model I added custom button which leads to custom action, code:
public function form_fields($values = array(), $related = array())
{
$this->form_builder->set_params(array('other_actions' => 'Place Order'));
$fields = parent::form_fields($values, $related);
...............
}

The question is:
Can I add customAction functionality into 'simple' module? and how can I do it?

Thank you.

Comments

  • edited 1:20PM
    It sounds like you may want to add some additional Javascript to your page to trigger your Place Order action. There are a couple areas in the documentation that may help with this but basically, for a module, you can include your own JS files, or you can assign them in your form_fields method.
    http://docs.getfuelcms.com/general/javascript#modules

    If you need to change the action of your form to place the order, you can use the following jQuery command in your javascript:
    $('#form').attr('action', 'fuel/my_module/place_order')
    In the above code, it assumes that there is a controller with a method on it of place_older. By default, all modules get routed to the fuel/modules controller. However, in some cases, your controller may need some extra methods. If it's an ajax request, you can add a method on your model of "ajax_place_order" and it can be accessed at fuel/my_module/ajax/place_order and any GET or POST parameters will be passed to it. This is a convenience that doesn't require you to create your own controller. In some cases though, you may want to create your own controller. The fuel/pages controller actually does this and essentially extends the fuel/module controller. Then any routes (e.g. $route['my_module/place_order'] => 'fuel/my_module/place_order';) can be added to the main fuel/application/config/routes.php file. The above assumes that you created a controller at main fuel/application/controllers/my_module.php with a method of place_order on it.
Sign In or Register to comment.