[eluser]Unknown[/eluser]
I am trying save a relationship table and this sent to me the following error:
Quote:Fatal error: Class name must be a valid object or a string /website/fuel/application/libraries/Datamapper.php on line 2514
This is the function in the controller
Code:
public function add_field($enumeration_id, $fields)
{
// OK: get enumeration
$enumeration = new Enumeration();
$enumeration->where('id', $enumeration_id)->get();
$field = new Field();
// OK: validate type
// if(is_json($fields))
// {
// $fields_array = json_decode($fields, true);
// $fields->where_in('id', $fields_array)->get();
// }
// else
// {
// }
$field->where('id', $fields)->get();
// TODO : maybe!! validate data of fields
// OK: save N to M
if (!$enumeration->save_fields($field->all))
{
add_error($enumeration->error->all);
return FALSE;
}
return TRUE;
}
Models:
Code:
class Enumeration extends DataMapper
{
public $model = 'enumeration';
public $table = 'enumerations';
// Insert related models that enumeration can have more than one of.
public $has_many = array('field');
}
class Field extends DataMapper
{
public $model = 'field';
public $table = 'fields';
// Insert related models that Field can have more than one of.
public $has_many = array('enumeration');
}
Any idea about this?