You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our module controller we can override the `indexData` to remove publish switch from modal. We can also override `setUpController` method to disable language select box used for making a translation active.
175
+
176
+
:::filename:::
177
+
`app/Http/Controllers/Twill/BlogController.php`
178
+
:::#filename:::
179
+
180
+
```phptorch
181
+
##CODE##
182
+
<?php
183
+
184
+
namespace App\Http\Controllers\Twill;
185
+
186
+
use A17\Twill\Http\Controllers\Admin\NestedModuleController as BaseModuleController;
187
+
use A17\Twill\Services\Forms\Fields\Input;
188
+
use A17\Twill\Services\Forms\Fields\Wysiwyg;
189
+
use A17\Twill\Services\Forms\Form;
190
+
191
+
class BlogController extends BaseModuleController
192
+
{
193
+
protected $moduleName = 'blogs';
194
+
195
+
public function getCreateForm(): Form
196
+
{
197
+
...
198
+
}
199
+
200
+
protected function setUpController(): void
201
+
{
202
+
$this->disablePublish();
203
+
$this->disableBulkPublish();
204
+
// $this->disableEditor(); # uncomment this to disable full editor
205
+
// $this->enableEditInModal(); # uncomment this to enable editing in modal
206
+
207
+
}
208
+
209
+
protected function formData($request)
210
+
{
211
+
return [ 'controlLanguagesPublication' => false ]; # disable select box to make language active
212
+
}
213
+
}
214
+
```
215
+
216
+
If we also want to make all languages active by default, we can override `prepareFieldsBeforeCreate` function in our module repository:
217
+
218
+
:::filename:::
219
+
`app/Repositories/BlogRepository.php`
220
+
:::#filename:::
221
+
222
+
```phptorch
223
+
##CODE##
224
+
<?php
225
+
226
+
namespace App\Repositories;
227
+
228
+
use A17\Twill\Repositories\Behaviors\HandleTranslations;
229
+
use A17\Twill\Repositories\Behaviors\HandleSlugs;
230
+
use A17\Twill\Repositories\ModuleRepository;
231
+
use App\Models\Category;
232
+
233
+
class BlogRepository extends ModuleRepository
234
+
{
235
+
use HandleTranslations, HandleSlugs;
236
+
237
+
public function __construct(Category $model)
238
+
{
239
+
$this->model = $model;
240
+
}
241
+
242
+
### make all languages active for this model
243
+
public function prepareFieldsBeforeCreate($fields): array
244
+
{
245
+
foreach ($fields['languages'] as $key => $language) {
0 commit comments