function definition($def = []) { $is = []; $row = null; $is = ['name' => (new TextBox())->id('name')->label('Page Name')->defaultValue($row ? $row->name : ''), 'description' => (new PlainTextAreaBox())->id('description')->label('Page Description')->defaultValue($row ? $row->description : ''), 'url' => (new TextBox())->id('url')->label('URL')->defaultValue($row ? $row->url : "/" . substr(md5(rand()), 0, 6)), 'template_id' => (new DropDown())->id('template_id')->nullable(false)->label('Template')->idField('id')->nameField('name')->rows(Template::get())->defaultValue($row ? $row->template_id : ''), 'language_id' => (new DropDown())->id('language_id')->nullable(false)->label('Language')->idField('id')->nameField('name')->rows(Language::get())->defaultValue($row ? $row->language_id : '')]; return parent::definition(['Form ID' => $this->getHeader() . "-form", 'Submit Button Text' => 'Save', 'Inputs' => $is]); }
function __construct() { parent::controllerClass('Pages'); parent::headerPlural('Pages'); parent::headerSingular('Page'); parent::baseRoute('/admin/pages'); parent::ajaxBaseRoute('/ajax/admin/pages'); parent::table(new Page()); parent::attributes([['title' => 'ID', 'id' => 'id'], ['title' => 'Name', 'id' => 'name'], ['title' => 'Description', 'id' => 'description'], ['title' => 'URL', 'id' => 'url'], ['title' => 'Template', 'id' => 'template.name'], ['title' => 'Language', 'id' => 'language.name']]); parent::inputs(function ($row) { return ['name' => (new TextBox())->id('name')->label('Name')->defaultValue($row ? $row->name : ''), 'description' => (new PlainTextAreaBox())->id('description')->label('Description')->defaultValue($row ? $row->description : ''), 'url' => (new TextBox())->id('url')->label('URL')->defaultValue($row ? $row->url : ''), 'template_id' => (new DropDown())->id('template_id')->nullable(false)->label('Template')->idField('id')->nameField('name')->rows(Template::get())->defaultValue($row ? $row->template_id : ''), 'language_id' => (new DropDown())->id('language_id')->nullable(false)->label('Language')->idField('id')->nameField('name')->rows(Language::get())->defaultValue($row ? $row->language_id : '')]; }); parent::tableName('page'); }