'display', 'create' => 'display']; //protected $model = User::class; /** * @var string */ protected $title; public function initialize() { $this->creating(function ($config, Model $model) { }); } /** * @var string */ protected $alias; /** * @return DisplayInterface */ public function onDisplay() { $form = AdminDisplay::datatablesAsync()->setDisplaySearch(true) ->setOrder([[0, 'desc']]) ->setHtmlAttribute('class', 'table-primary') ->setColumns( AdminColumn::link('id', '#')->setWidth('30px'), AdminColumnEditable::text('name', 'Name')->setWidth('100px'), AdminColumn::link('email', 'Email')->setWidth('100px') )->paginate(20); return $form; } /** * @param int $id * * @return FormInterface */ public function onEdit($id) { function product($id) { $formElement = []; if($id != null){ $category = User::find($id)->id; $formElement[] = AdminSection::getModel(Location::class)->fireDisplay(['user_id' => $category]); } return $formElement; }; $formElements = [ AdminFormElement::text('name', 'Name')->required(), AdminFormElement::text('email', 'Name')->required(), ]; $tabs = AdminDisplay::tabbed([ 'General' => new FormElements($formElements), 'Locations' => new FormElements(product($id)), ]); $context = empty($id) ? $formElements : $tabs; $form = AdminForm::panel(); $form->addBody($context); $form->getButtons()->setButtons([ 'save' => new Save(), 'cancel' => new Cancel(), ]); return $form; } /** * @return FormInterface */ public function onCreate() { return $this->onEdit(null); } /** * @return void */ public function onDelete($id) { // remove if unused } /** * @return void */ public function onRestore($id) { // remove if unused } }