public function register() { FormItem::register('columns', \KodiCMS\SleepingOwlAdmin\FormItems\Columns::class); FormItem::register('text', \KodiCMS\SleepingOwlAdmin\FormItems\Text::class); FormItem::register('time', \KodiCMS\SleepingOwlAdmin\FormItems\Time::class); FormItem::register('date', \KodiCMS\SleepingOwlAdmin\FormItems\Date::class); FormItem::register('timestamp', \KodiCMS\SleepingOwlAdmin\FormItems\Timestamp::class); FormItem::register('textaddon', \KodiCMS\SleepingOwlAdmin\FormItems\TextAddon::class); FormItem::register('select', \KodiCMS\SleepingOwlAdmin\FormItems\Select::class); FormItem::register('multiselect', \KodiCMS\SleepingOwlAdmin\FormItems\MultiSelect::class); FormItem::register('hidden', \KodiCMS\SleepingOwlAdmin\FormItems\Hidden::class); FormItem::register('checkbox', \KodiCMS\SleepingOwlAdmin\FormItems\Checkbox::class); FormItem::register('ckeditor', \KodiCMS\SleepingOwlAdmin\FormItems\CKEditor::class); FormItem::register('custom', \KodiCMS\SleepingOwlAdmin\FormItems\Custom::class); FormItem::register('password', \KodiCMS\SleepingOwlAdmin\FormItems\Password::class); FormItem::register('textarea', \KodiCMS\SleepingOwlAdmin\FormItems\Textarea::class); FormItem::register('view', \KodiCMS\SleepingOwlAdmin\FormItems\View::class); FormItem::register('image', \KodiCMS\SleepingOwlAdmin\FormItems\Image::class); FormItem::register('images', \KodiCMS\SleepingOwlAdmin\FormItems\Images::class); FormItem::register('file', \KodiCMS\SleepingOwlAdmin\FormItems\File::class); FormItem::register('radio', \KodiCMS\SleepingOwlAdmin\FormItems\Radio::class); FormItem::register('wysiwyg', \KodiCMS\SleepingOwlAdmin\FormItems\Wysiwyg::class); }
<?php use KodiCMS\Users\Model\User; use KodiCMS\Users\Model\UserRole; use KodiCMS\SleepingOwlAdmin\Filter\Filter; use KodiCMS\SleepingOwlAdmin\Columns\Column; use KodiCMS\SleepingOwlAdmin\Filter\FilterBase; use KodiCMS\SleepingOwlAdmin\FormItems\FormItem; use KodiCMS\SleepingOwlAdmin\Display\DisplayTabbed; use KodiCMS\SleepingOwlAdmin\Model\ModelConfiguration; SleepingOwlModule::registerModel(User::class, function (ModelConfiguration $model) { $model->setTitle('User')->onDisplay(function () { $display = SleepingOwlDisplay::tabbed(); $display->setTabs(function (DisplayTabbed $tabbed) { $tabbed->appendDisplay(SleepingOwlDisplay::table()->setFilters([Filter::field('name')->setOperator(FilterBase::BEGINS_WITH)->setValue('ad')])->setColumns([Column::link('name')->setLabel('name'), Column::lists('roles.name')->setLabel('Roles')->setWidth('300px'), Column::email('email')->setLabel('E-mail')->setWidth('200px')]), 'First Tab'); $tabbed->appendDisplay(SleepingOwlDisplay::table()->setColumns([Column::link('username')->setLabel('Username')]), 'Second Tab'); }); return $display; })->onCreateAndEdit(function () { $form = SleepingOwlForm::form(); $form->setItems(FormItem::columns()->addColumn(function () { return [FormItem::wysiwyg('name', 'Username', 'ace')->required(), FormItem::text('email', 'E-mail')->required()->addValidationRule('email'), FormItem::timestamp('created_at', 'Date creation'), FormItem::multiselect('roles', 'Roles')->setModelForOptions(new UserRole())->setDisplay('name')]; })); return $form; }); })->addMenuLink(User::class)->setIcon('users');