laravel-enso / enso

Laravel Vue SPA, Bulma themed. For demo login use `admin@laravel-enso.com` & `password` -
https://www.laravel-enso.com
MIT License
1.08k stars 277 forks source link

The question is: How can I use a custom form for people on version 3.5.0? #250

Closed elysiopires closed 5 years ago

elysiopires commented 5 years ago

This is a question...

Prerequisites

Description

I was trying to do the same thing that I did before with a project using enso 3.3.5, replace the people form template and table template too.

On this version, I could only change the config/people.php and change the lines bellow pointing to my custom files:

return [ 'formTemplate' => null, 'tableTemplate' => null, ];

Since version 3.4.0(people package people 2.2.*) this file goes away... and I saw the version 3.5.0 and still missing... so I checked the change backlog and I found:

people

improves form for easier customization adds AvoidsDeletionConflicts, Relations, Rememberable on Person adds laravel-enso/enums adds EnumServiceProvider adds bank and bank_account to the table's migration adds uid to $queryAttributes in Option removes people.php config file

So the question is: How can I use my custom form template for people, company or any enso package?

Sincerely, Elysio

Steps to Reproduce

Expected behavior

Use a custom form template on enso.

Actual behavior

Cannot use anymore file config/people.php to set my custom form to people.

aocneanu commented 5 years ago

Hi @elysiopires,

Create a local versions for CompanyForm.php and CompanyTable.php that can extend the ones in laravel-enso/companies and customize exactly what you need.

For instance since the TemplatePath constant is protected, you can only override that if you only need a different template.

Then make sure that in the local AppServiceProvider you add to the bindings prop the local classes

public $bindings = [
    CoreCompanyForm::class => CompanyForm::class, //(CompanyForm is the local class)
    CoreCompanyTable::class => CompanyTable::class, //(CompanyTable is the local class)
]

Since in the controllers we resolve the builder class from Laravel's service container this should be everything.

elysiopires commented 5 years ago

Hello @aocneanu !

Worked like a charm!

Thx for your support... You could add this to Enso Documentation!

Thx, Elysio Pires