Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
The module saves correctly in database as json field. But in backend after a page reload the image doesn't display, showing an empty field. After that, new saves store empty values.
Steps to reproduce
In my App/Http/Controllers/Twill/ModuleNameController.php :
Added an InlineRepeater field inside fieldset, then added Medias field inside the repeater.
<?php
namespace App\Http\Controllers\Twill;
use A17\Twill\Models\Contracts\TwillModelContract;
use A17\Twill\Services\Forms\Fields\Files;
use A17\Twill\Services\Forms\Fields\Medias;
use A17\Twill\Services\Forms\Fields\Repeater;
use A17\Twill\Services\Forms\Fields\Wysiwyg;
use A17\Twill\Services\Forms\Fieldset;
use A17\Twill\Services\Forms\Fieldsets;
use A17\Twill\Services\Forms\InlineRepeater;
use A17\Twill\Services\Listings\Columns\Text;
use A17\Twill\Services\Listings\TableColumns;
use A17\Twill\Services\Forms\Fields\Input;
use A17\Twill\Services\Forms\Form;
use A17\Twill\Http\Controllers\Admin\SingletonModuleController as BaseModuleController;
use App\Models\Home;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
class HomeController extends BaseModuleController
{
protected $moduleName = 'homes';
protected $previewView = 'pages.home';
protected function previewData($item)
{
$presentation_url = $item->file('presentation_url');
return [
'content' => $item,
'presentation_url' => $presentation_url
];
}
/**
* See the table builder docs for more information. If you remove this method you can use the blade files.
* When using twill:module:make you can specify --bladeForm to use a blade form instead.
*/
public function getForm(TwillModelContract $model): Form
{
$form = Form::make();
$form->withFieldSets(new Fieldsets([
Fieldset::make()->title('Services')->id('services')->fields([
InlineRepeater::make()->name('services')->label('Service')
->fields([
Medias::make()
->name('cover')
->label(twillTrans('Cover image'))
->translatable()
->max(1),
Input::make()->name('title')->translatable(),
Wysiwyg::make()
->name('lead')
->toolbarOptions([ [ 'header' => [1, 2, false] ], 'ordered', 'bullet' ])
->maxLength(200)
->translatable(),
])
]),
]));
return $form;
}
/**
* This method can be used to enable/disable defaults. See setUpController in the docs for available options.
*/
protected function setUpController(): void
{
$this->disablePermalink();
$this->disableEditor();
$this->disablePublish();
}
}
2. Added configurations in my model :
<?php
namespace App\Models;
use A17\Twill\Models\Behaviors\HasBlocks;
use A17\Twill\Models\Behaviors\HasTranslation;
use A17\Twill\Models\Behaviors\HasMedias;
use A17\Twill\Models\Behaviors\HasRevisions;
use A17\Twill\Models\Behaviors\HasFiles;
use A17\Twill\Models\Model;
class Home extends Model
{
use HasBlocks;
use HasFiles;
use HasMedias;
use HasRevisions;
use HasTranslation;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
Run the migrations.
*/
public function up(): void
{
Schema::table('homes', function (Blueprint $table) {
$table->json('services')->nullable();
});
Schema::table('home_translations', function (Blueprint $table) {
$table->json('services')->nullable();
});
}
/**
Reverse the migrations.
*/
public function down(): void
{
Schema::table('homes', function (Blueprint $table) {
$table->dropColumn('services');
});
Schema::table('home_translations', function (Blueprint $table) {
$table->dropColumn('services');
});
}
};
### Expected result
After saving the module from backend, the content store in database. After reload the backend page, the images show in repeater fields
### Actual result
After saving the module from backend, the content store in database. After reload the backend page, cant see the images stored in database
### Versions
Twill version: 3.0
Laravel version: 11
PHP version: 8.2
Database engine: MySql
Description
The module saves correctly in database as json field. But in backend after a page reload the image doesn't display, showing an empty field. After that, new saves store empty values.
Steps to reproduce
namespace App\Http\Controllers\Twill;
use A17\Twill\Models\Contracts\TwillModelContract; use A17\Twill\Services\Forms\Fields\Files; use A17\Twill\Services\Forms\Fields\Medias; use A17\Twill\Services\Forms\Fields\Repeater; use A17\Twill\Services\Forms\Fields\Wysiwyg; use A17\Twill\Services\Forms\Fieldset; use A17\Twill\Services\Forms\Fieldsets; use A17\Twill\Services\Forms\InlineRepeater; use A17\Twill\Services\Listings\Columns\Text; use A17\Twill\Services\Listings\TableColumns; use A17\Twill\Services\Forms\Fields\Input; use A17\Twill\Services\Forms\Form; use A17\Twill\Http\Controllers\Admin\SingletonModuleController as BaseModuleController; use App\Models\Home; use Illuminate\Support\Facades\Cache; use Illuminate\View\View;
class HomeController extends BaseModuleController { protected $moduleName = 'homes';
}
<?php
namespace App\Models;
use A17\Twill\Models\Behaviors\HasBlocks; use A17\Twill\Models\Behaviors\HasTranslation; use A17\Twill\Models\Behaviors\HasMedias; use A17\Twill\Models\Behaviors\HasRevisions; use A17\Twill\Models\Behaviors\HasFiles; use A17\Twill\Models\Model;
class Home extends Model { use HasBlocks; use HasFiles; use HasMedias; use HasRevisions; use HasTranslation;
}
<?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema;
return new class extends Migration { /**
Run the migrations. */ public function up(): void { Schema::table('homes', function (Blueprint $table) { $table->json('services')->nullable(); });
}
/**
Reverse the migrations. */ public function down(): void { Schema::table('homes', function (Blueprint $table) { $table->dropColumn('services'); });
} };