Edit Add Buttons in has_many multi-field v1.0
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
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?
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>" );
class Scratch_image_model extends Base_module_record { }
class Scratch_image_model extends Base_module_record { }
Didn't make any difference but should I add any variables to it?
<?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 } }
https://github.com/daylightstudio/FUEL-CMS/commit/78083ce8cd3deda2005fce69fb2e9d3a626f372f