Edit Add Buttons in has_many multi-field v1.0

edited February 2013 in Bug Reports
I assume this is a bug but when all I do is place a 'has_many' at the top of a model it works perfectly. Saves the data, etc. However, in the multi-field the Edit and Add buttons produce a 404 page in the popup modal. The Add button sends you to /fuel//inline_create and the Edit button sends you to /fuel//inline_edit/{id}

I looked in my fuel_relationships table and it appears the {id} is the foreign_key field which is perfect. It just seems to be missing the table name part of the URI. In this case, my table is named scratch_images so it should be-> /fuel/scratch_images/inline_edit/{id} which works.

Comments

  • edited 5:39AM
    is scratch_images a simple module with an entry in MY_fuel_modules.php?
  • edited 5:39AM
    yes.
  • edited 5:39AM
    Are the Edit and Add buttons only supposed to work with Advanced modules?
  • edited 5:39AM
    They should work for simple modules only actually although simple modules can exist inside an advanced module.
    If you inspect the select form field, does it have a class of something like the following:
    class="field_type_multi add_edit scratch_images"
    The 3rd class name should be the name of the module that it maps to. I'm guessing yours is blank? If so, it probably has something to do with it not finding the scratch_images simple module. That is determined on line 376 of the Fuel_custom_fields.php class.

    What is the module configuration for scratch_images in MY_fuel_modules.php?
  • edited February 2013
    yea, it says: class="field_type_multi add_edit " so it IS missing the module name.

    Here's the scratch_images_model.php contents:
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Scratch_images_model extends Base_module_model { //public $required = array(); function __construct() { parent::__construct('scratch_images'); //table } function list_items($limit = NULL, $offset = NULL, $col = 'scratch_image', $order = 'asc') { $this->db->select('id, scratch_image, image_type', FALSE); $data = parent::list_items($limit, $offset, $col, $order); foreach($data as $key => $value) { $data[$key]['scratch_image'] = '<img style="max-width: 20%;" src="'.img_path($value['scratch_image']).'" />'; } return $data; } function form_fields($values = array(), $related = array()) { $fields = parent::form_fields($values, $related); $fields['scratch_image'] = array('type' => 'asset', 'folder' => 'images', 'subfolder' => 'scratch_sets', 'overwrite' => TRUE); return $fields; } }
    And here's how I have the module defined in My_fuel_modules:
    $config['modules']['scratch_images'] = array( 'module_name'=>'Scratch Game Images', 'instructions' => "<h2>Scratch Game Images</h2><p>This area is for managing the images to be used for image theme packs. Upload or choose an image and save it here as either a win, lose or cover image. Then go to the Scratch Image Themes area and add this image to an existing or new theme set.</p>" );
  • edited 5:39AM
    What happens if you add a Record class below it of "class Scratch_image_model" that extends Base_module_record?
    class Scratch_image_model extends Base_module_record { }
  • edited 5:39AM
    I added it at the bottom of the scratch_images model empty like this:

    class Scratch_image_model extends Base_module_record { }
    Didn't make any difference but should I add any variables to it?
  • edited 5:39AM
    Here's the image_themes_model. Might be something missing there:
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Image_themes_model extends Base_module_model { public $required = array('theme_name','game_type_id'); public $foreign_keys = array('game_type_id' => 'game_types_model'); public $has_many = array('scratch_images' => array('app' => 'scratch_images_model')); function __construct() { parent::__construct('image_themes'); //table } }
  • edited 5:39AM
    I found the issue. It had to do with the name having an underscore in it and the method being used to get the name of the module. That should be fixed in the latest push:
    https://github.com/daylightstudio/FUEL-CMS/commit/78083ce8cd3deda2005fce69fb2e9d3a626f372f
  • edited February 2013
    Yep, that did it! Wow, thanks so much.
Sign In or Register to comment.