This topic contains 2 replies, has 2 voices, and was last updated by Attila Fabrik 6 years, 5 months ago.
- Topic
Hi,
I’m using OroPlatform 2.2.3. and created a custom entity (Finance) over the GUI but also have and extend entity (Contract). Now I would like to render the Finance datagrid as widget inside the Contract view.
When I click on the datagrid item to load the view I get the following error:
An exception has been thrown during the rendering of a template (“The path “query.from.0.table” cannot contain an empty value, but got null.”) in src/NavisionBundle/Resources/views/Contract/widget/finance.html.twig at line 5.
Can you help me figuring out what is the problem here? (I have data in all tables)
Here is my implementation (based on the Oro MagentoBundle and DataGridBundle documentation):view.html.twig
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667{# Resources/views/Contract/view.html.twig #}{% extends 'OroUIBundle:actions:view.html.twig' %}{% import 'OroUIBundle::macros.html.twig' as UI %}{# Import for the Comments #}{% import 'OroEntityConfigBundle::macros.html.twig' as entityConfig %}{% block pageHeader %}{% set breadcrumbs = {'entity': entity,'indexPath': path('nav_contract_index'),'indexLabel': 'Contract'|trans,'entityTitle': entity.no} %}{{ parent() }}{% endblock pageHeader %}{% block content_data %}{% set data %}<div class="widget-content"><div class="row-fluid form-horizontal"><div class="responsive-block">{{ UI.renderProperty('Contract No.'|trans, entity.no) }}{#{{ UI.renderProperty('Tenant ID'|trans, entity.renterNo) }}#}{{ UI.renderProperty('Guarantee Amount'|trans, entity.guaranteeAmount|oro_format_decimal) }}{{ UI.renderProperty('Rental Start'|trans, entity.mietbeginn|oro_format_date) }}{{ UI.renderProperty('Guarantor exists'|trans, entity.contractSigndate|oro_format_date) }}{{ UI.renderProperty('Updated'|trans, entity.lastTimeModified|oro_format_datetime) }}{{ UI.renderProperty('Updated By'|trans, entity.lastTimeModifiedBy) }}</div></div></div>{% endset %}{# Finance datagrid as widget #}{% set financeWidget %}{{ oro_widget_render({'widgetType': 'block','url': path('nav_contract_widget_finance', {id: entity.id})}) }}{% endset %}{% set dataBlocks = dataBlocks|merge([{'title': 'Financial Documents'|trans,'subblocks': [{'data' : [financeWidget] }]}]) %}{# Comments #}{%- set commentsData -%}{% placeholder view_content_data_comments with {entity: entity} %}{%- endset -%}{% set dataBlocks = [{'title': 'Data'|trans,'class': 'active','subblocks': [{ 'data' : [data] }]}] %}{{ parent() }}{% endblock content_data %}finance.html.twig
123456{# Resources/views/Contract/widget/finance.html.twig #}{% import 'OroDataGridBundle::macros.html.twig' as dataGrid %}<div class="widget-content">{{ dataGrid.renderGrid('custom-entity-grid', {entityName: 'Extend_Entity_Finance'}) }}</div>ContractController.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859<?php/*** @author Attila Fabrik <a.fabrik@kautionskasse.de>* @copyright 2017 Deutsche Kautionskasse AG (https://www.kautionskasse.de)** LICENSE:** For the full copyright and license information, please view the LICENSE* file that was distributed with this source code.*/namespace NavisionBundle\Controller;use NavisionBundle\Entity\Contract;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;use Symfony\Bundle\FrameworkBundle\Controller\Controller;class ContractController extends Controller{/*** @Route("/contract", name="nav_contract_index")* @Template()*/public function indexAction(){return array('gridName' => 'nav-contract-grid');}/*** View entity (in the UI it's the selected "datagrid" row)** @Route("/contract/{id}", name="nav_contract_view", requirements={"id"="\d+"})* @Template()** @param Contract $contract** @return array*/public function viewAction(Contract $contract){// Here we have to use 'entity' otherwise it will not work!// https://oroinc.com/orocrm/forums/topic/variable-entity-does-not-exist-errorreturn array('entity' => $contract);}/*** @Route("/widget/grid/{id}", name="nav_contract_widget_finance", requirements={"id"="\d+"}))* @Template** @param Contract $contract** @return array*/public function financeAction(Contract $contract){return ['entity' => $contract];}}
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.