-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
80 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ | |
* ]; | ||
* } | ||
* ``` | ||
* | ||
* | ||
* The plugin stores the value of the selected checkbox items as json into the database. | ||
* | ||
* @author Basil Suter <[email protected]> | ||
*/ | ||
class CheckboxList extends Plugin | ||
|
@@ -66,7 +68,7 @@ protected function getItems() | |
/** | ||
* @inheritdoc | ||
*/ | ||
public function serviceData() | ||
public function serviceData($event) | ||
{ | ||
return ['checkboxitems' => $this->getItems()]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ | |
* return $model->firstname . ' ' . $model->lastname; | ||
* } | ||
* ``` | ||
* | ||
* You can also use the quick mode which finds the primary key by itself, therfore just keep valueField empty. | ||
* @author Basil Suter <[email protected]> | ||
*/ | ||
class SelectModel extends Select | ||
|
@@ -156,7 +158,12 @@ public function getData() | |
$class = $class::className(); | ||
} | ||
|
||
if (!$this->valueField) { | ||
$this->valueField = implode("", $class::primaryKey()); | ||
} | ||
|
||
foreach (static::getDataInstance($class, $this->where) as $item) { | ||
|
||
$data[] = [ | ||
'value' => (int) $item->{$this->valueField}, | ||
'label' => $this->generateLabelField($item), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ public function testGetServiceDataConfiguration() | |
$this->assertSame([ | ||
0 => ['value' => 1, 'label' => 'John Doe ([email protected])'], | ||
1 => ['value' => 2, 'label' => 'Jane Doe ([email protected])'] | ||
], $plugin->serviceData()['relationdata']['items']); | ||
], $plugin->serviceData($event)['relationdata']['items']); | ||
} | ||
|
||
public function testGetServiceDataNoTemplateConfiguration() | ||
|
@@ -64,7 +64,7 @@ public function testGetServiceDataNoTemplateConfiguration() | |
$this->assertSame([ | ||
0 => ['value' => 1, 'label' => 'John, Doe'], | ||
1 => ['value' => 2, 'label' => 'Jane, Doe'] | ||
], $plugin->serviceData()['relationdata']['items']); | ||
], $plugin->serviceData($event)['relationdata']['items']); | ||
} | ||
|
||
public function testGetServiceDataCallablaeConfiguration() | ||
|
@@ -87,13 +87,13 @@ public function testGetServiceDataCallablaeConfiguration() | |
'refModelPkId' => 'group_id', | ||
'refJoinPkId' => 'user_id', | ||
'labelFields' => function ($model) { | ||
return $model->firstname . "|". $model->lastname; | ||
return $model['firstname'] . "|". $model['lastname']; | ||
} | ||
]); | ||
|
||
$this->assertSame([ | ||
0 => ['value' => 1, 'label' => 'John|Doe'], | ||
1 => ['value' => 2, 'label' => 'Jane|Doe'] | ||
], $plugin->serviceData()['relationdata']['items']); | ||
], $plugin->serviceData($event)['relationdata']['items']); | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
modules/admin/tests/admin/ngrest/plugins/SelectHasManyTest.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters