简体   繁体   中英

Grocery Crud display image from another table

I am trying to display a image in grocery crud edit from another table. Have provided the relation it is just displaying the file name and not the image. Below is my code let me know where I need to correct. Also don't want to update the image in my edit table (inwardinventory). just need to display it based on selection of sacoskucode column from mastersku table.

            public function entry()
                {
                        $crud = new grocery_CRUD();

                        //$crud->set_theme('datatables');
                        $crud->unset_delete();

                        $crud->set_table('inwardinventory');
                        $crud->set_primary_key('SacoSku','inwardinventory');
                        $crud->set_relation('SacoSku','mastersku','SacoSku');
                        $crud->set_relation('PdtImage','mastersku','PdtImage');
                        $crud->set_field_upload('PdtImage','assets/uploads/files');
                        $crud->set_subject('In Out Stock');
                        $crud->field_type('TranscationType','dropdown',
                        array('IN' => 'Inward / Purchase','OUT' => 'Out Ward / Sale / Basement'));
                        $output = $crud->render();

                        $this->_example_output($output);
            }   

You can provide tables structure with the question to give you exactly the answer;

  • according to the documentation of grocery crud website the set_relation function accept the parameters:

    set_relation($field_name ,$related_table,$related_title_field)

    if your database schema like this:

tblOne(id, refImageID)

tblImage(id, imagePath) the set relation function must be like this:

$crud->set_relation('refImageID','tblImage','imagePath');
  • to avoid edit amage and just display it add the line $crud->fields(array("feilds", "to", "edit"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM