Skip to content

Commit

Permalink
Merge pull request #449 from solewniczak/fix-bureaucracy-handle-looku…
Browse files Browse the repository at this point in the history
…p-fields-for-lookup-descendants

Fix bureaucracy handle lookup fields for Lookup type descendents
  • Loading branch information
splitbrain committed Apr 30, 2019
2 parents 596c151 + e46eaff commit 40c2e1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions action/bureaucracy.php
Expand Up @@ -13,6 +13,7 @@
use dokuwiki\plugin\struct\meta\Assignments;
use dokuwiki\plugin\struct\meta\Schema;
use dokuwiki\plugin\struct\meta\Search;
use dokuwiki\plugin\struct\types\Lookup;

/**
* Handles bureaucracy additions
Expand Down Expand Up @@ -85,7 +86,7 @@ public function handle_schema(Doku_Event $event, $param) {
public function handle_lookup_fields(Doku_Event $event, $param) {
foreach($event->data['fields'] as $field) {
if(!is_a($field, 'helper_plugin_struct_field')) continue;
if($field->column->getType()->getClass() != 'Lookup') continue;
if(!$field->column->getType() instanceof Lookup) continue;

$value = $field->getParam('value');
if (!is_array($value)) $value = array($value);
Expand Down Expand Up @@ -140,7 +141,7 @@ public function handle_save(Doku_Event $event, $param) {
$lbl = $field->column->getLabel();
if(!isset($tosave[$tbl])) $tosave[$tbl] = array();

if ($field->column->isMulti() && $field->column->getType()->getClass() == 'Lookup') {
if ($field->column->isMulti() && $field->column->getType() instanceof Lookup) {
$tosave[$tbl][$lbl] = $field->opt['struct_pids'];
} else {
$tosave[$tbl][$lbl] = $field->getParam('value');
Expand Down
3 changes: 2 additions & 1 deletion helper/field.php
Expand Up @@ -4,6 +4,7 @@
use dokuwiki\plugin\struct\meta\StructException;
use dokuwiki\plugin\struct\meta\Value;
use dokuwiki\plugin\struct\meta\ValueValidator;
use dokuwiki\plugin\struct\types\Lookup;

/**
* Allows adding a single struct field as a bureaucracy field
Expand Down Expand Up @@ -86,7 +87,7 @@ public function renderfield($params, Doku_Form $form, $formid) {

// output the field
$value = new Value($this->column, $this->opt['value']);
if ($this->column->getType()->getClass() == 'Lookup') {
if ($this->column->getType() instanceof Lookup) {
$value->setValue($this->opt['value'], true);
}
$field = $this->makeField($value, $params['name']);
Expand Down

0 comments on commit 40c2e1c

Please sign in to comment.