class CubistCrudPanel extends CrudPanel
{
protected $_seenFieldTypes = [];
+ protected $_values = [];
public function hasField($name)
{
return $this->getEntry($this->getCurrentEntryId());
}
+ public function getValue($key, $default = null)
+ {
+ if (isset($this->_values[$key])) {
+ return $this->_values[$key];
+ }
+ return $default;
+ }
+
+ public function setValue($key, $value)
+ {
+ $this->_values[$key] = $value;
+ }
+
public function checkIfFieldIsFirstOfItsType($field)
{
$type = $field['type'];
public function getDefaultAttributes()
{
- return array_merge(parent::getDefaultAttributes(), ['attribute' => 'name', 'allows_null' => false, 'allows_multiple' => $this->_multiple]);
+ return array_merge(parent::getDefaultAttributes(), ['attribute' => 'name', 'column_attribute' => null, 'allows_null' => false, 'allows_multiple' => $this->_multiple]);
}
protected function _getOptions()
if ($i instanceof CubistMagicAbstractModel) {
$f = $i->getField($e[0]);
if ($f instanceof Model) {
- return $f->pluck($e[1])[$v0];
+ $a = $f->pluck($e[1]);
+ if (isset($a[$v0])) {
+ return $a[$v0];
+ }
+ return '-';
}
}
}
public function getColumnData()
{
$res = parent::getColumnData();
- $res['options'] = $this->_getOptions();
+ $res['options'] = $this->_getColumnOptions();
return $res;
}
+
+ protected function _getColumnOptions()
+ {
+ $ca = $this->getAttribute('column_attribute');
+ if (null === $ca || $this->getAttribute('attribute') === $ca) {
+ return $this->_getOptions();
+ }
+
+ return $this->pluck($this->getAttribute('column_attribute'));
+ }
}