简体   繁体   English

Grocery Crud 显示来自另一个表的图像

[英]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).也不想更新我的编辑表(inwardinventory)中的图像。 just need to display it based on selection of sacoskucode column from mastersku table.只需要根据从 mastersku 表中选择 sacoskucode 列来显示它。

            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 函数接受参数:

    set_relation($field_name ,$related_table,$related_title_field) set_relation($field_name,$related_table,$related_title_field)

    if your database schema like this:如果您的数据库架构是这样的:

tblOne(id, refImageID) tblOne(id, refImageID)

tblImage(id, imagePath) the set relation function must be like this: tblImage(id, imagePath) 设置的关系函数必须是这样的:

$crud->set_relation('refImageID','tblImage','imagePath');
  • to avoid edit amage and just display it add the line $crud->fields(array("feilds", "to", "edit"));为避免编辑 amage 并仅显示它,请添加行 $crud->fields(array("feilds", "to", "edit"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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