Skip to content

Commit

Permalink
Merge pull request #7 from jplhomer/allow-array-casting
Browse files Browse the repository at this point in the history
Allow native array casting
  • Loading branch information
Tarpsvo authored Aug 20, 2019
2 parents 5a38be5 + f015a82 commit 929e539
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ composer require optimistdigital/nova-multiselect-field

## Usage

The field is used similarly to Nova's native Select field. The field type in the database should be text-based (ie `string`, `text` or `varchar`), selected values are stored as a JSON array.
The field is used similarly to Nova's native Select field. The field type in the database should be text-based (ie `string`, `text` or `varchar`), selected values are stored as a stringified JSON array.

```php
use OptimistDigital\MultiselectField\Multiselect;
Expand Down
2 changes: 1 addition & 1 deletion dist/js/multiselect-field.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/js/components/DetailField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
values() {
if (!this.field.value) return;
const valuesArray = JSON.parse(this.field.value);
const valuesArray = Array.isArray(this.field.value) ? this.field.values : JSON.parse(this.field.value);
if (!Array.isArray(valuesArray) || !valuesArray.length) return;
return valuesArray
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/IndexField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
value() {
if (!this.field.value) return '-';
const valuesArray = JSON.parse(this.field.value);
const valuesArray = Array.isArray(this.field.value) ? this.field.value : JSON.parse(this.field.value);
if (!Array.isArray(valuesArray)) return '-';
const values = valuesArray
Expand Down

0 comments on commit 929e539

Please sign in to comment.