Skip to content

Commit 2cbdace

Browse files
authored
Merge pull request #12 from wize-wiz/master
Enable alwaysShow() option
2 parents 351e5c8 + d58a099 commit 2cbdace

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,16 @@ You can also pass in an array of options to use with Trumbowyg
4747
];
4848
}
4949
```
50+
51+
By default, the Trumbowyg field will not display their content when viewing a resource on its detail page. It will be hidden behind a "Show Content" link, that when clicked will reveal the content. You may specify the Trumbowyg field should always display its content by calling the alwaysShow method on the field itself
52+
53+
```
54+
public function fields(Request $request)
55+
{
56+
return [
57+
...,
58+
NovaTrumbowyg::make('body')->alwaysShow(),
59+
...
60+
];
61+
}
62+
```

src/NovaTrumbowyg.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace Johnathan\NovaTrumbowyg;
44

5+
use Laravel\Nova\Fields\Expandable;
56
use Laravel\Nova\Fields\Field;
67

78
class NovaTrumbowyg extends Field
89
{
10+
use Expandable;
11+
912
/**
1013
* The field's component.
1114
*
@@ -17,4 +20,16 @@ public function options(array $options = [])
1720
{
1821
return $this->withMeta(['options' => $options]);
1922
}
23+
24+
/**
25+
* Prepare the element for JSON serialization.
26+
*
27+
* @return array
28+
*/
29+
public function jsonSerialize()
30+
{
31+
return array_merge(parent::jsonSerialize(), [
32+
'shouldShow' => $this->shouldBeExpanded(),
33+
]);
34+
}
2035
}

0 commit comments

Comments
 (0)