Jump to content


How to call a function from custom model?

custom model set_model

  • Please log in to reply
2 replies to this topic

#1 Qarlo

Qarlo

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 10 November 2017 - 01:44 PM

Hello,

I was trying to set up a custom model.

 

I followed the example from the set_model documentation page:

https://www.groceryc...tions/set_model

 

In the example a function called "get_relation_n_n_unselected_array" is defined. What I find strange is that this function never gets called.

 

So in my code I tried the following:

public function edit_photo()
{
$this->view = false;

$crud = new grocery_CRUD();

$crud->set_model('My_Custom_model');
$crud->set_theme('datatables');
$crud->my_function();
...
class My_Custom_model extends grocery_CRUD_Model {

    function my_function()
    {
        echo 'test';
    }
}

I made sure that the custom model is inside the models directory.

 

I get an error that my_function is undefined.

 

What am I doing wrong?

 



#2 caramayson

caramayson

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 17 August 2018 - 10:11 AM

When you characterize the parameters, you have the alternative of simply writing in the parameter name or giving them a default esteem. You'll see the greater part of the parameters are compared to some esteem. These are their default esteems.



#3 mp3man

mp3man

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 17 July 2019 - 04:50 PM

Just replace your call...

$crud->my_function();

by this one:

$crud->basic_model->my_function();






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users