Comments (2)
From @jonathangreco on June 2, 2015 13:47
I think you inversed column and table values.
Column should be with 'p' value.
table should be with 'name' value.
This seems to work.
from zfc-datagrid.
From @olexp on June 2, 2015 16:12
It seems you didn't read the example code. 'p' stands for 'Application\Entity\Product'. It couldn't be column. Also alias in exception (p_name) created for name.p should say that it is something wrong.
Let me explain what really happens in code.
This part of Datagrid.php works correctly:
if ('ZfcDatagrid\\Column\\Select' == $class) {
if (! isset($config['select']['column'])) {
throw new \InvalidArgumentException('For "ZfcDatagrid\Column\Select" the option select[column] must be defined!');
}
$table = isset($config['select']['table']) ? $config['select']['table'] : null;
$instance = new $class($config['select']['column'], $table);
} else {
and we have instance of Select in $instance. Few lines below it there is loop:
foreach ($config as $key => $value) {
$method = 'set'.ucfirst($key);
if (method_exists($instance, $method)) {
if (in_array($key, $this->specialMethods)) {
if (! is_array($value)) {
$value = array(
$value,
);
}
call_user_func_array(array(
$instance,
$method,
), $value);
} else {
call_user_func(array(
$instance,
$method,
), $value);
}
}
}
When it comes to 'select' key the method 'setSelect' is triggered on $instance and that's where the values of table and column switched. setSelect is called with $value = array('column' => 'name', 'table' => 'p') that magically transforms to setSelect('name', 'p'). Order here is important and it could be changed in action ($grid->addColumn()) but executing method call like this is unsafe.
As I already wrote, skipping key with 'select' value in loop could help.
from zfc-datagrid.
Related Issues (20)
- Todo for 2.0 HOT 7
- Custom query HOT 1
- Error rendering NULLs in DateTime columns with PHPExcel HOT 2
- Use route for links or action buttons HOT 3
- Disable cache HOT 7
- Filters - Extended
- Support native ZF Event HOT 2
- Daterange Not working for Doctrine2 Datasource
- Cannot use ZfcDatagrid\Column\DataPopulation\Object as Object because 'Object' HOT 3
- The expediency of using the MvcEvent HOT 6
- Configuration conflict when set non-default cache adapter HOT 3
- Get value from another column HOT 1
- Allow changing column type's `filterDefaultOperation` HOT 1
- Drop support for PHP 5.6 and 7.0 HOT 3
- Implement all filters in ZfcDatagrid\Renderer\JqGrid\View\Helper\Columns::getStyles HOT 3
- Possibility set a column position HOT 1
- Package phpoffice/phpexcel is abandoned HOT 1
- bootstrap v4 template HOT 1
- Add datagrid filters instead of using the columns filters
- TypeError when applying toobar filter on grid with PhpArray datasource and null value in data HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zfc-datagrid.