Skip to content
Advertisement

Laravel Backpack – Set extra attributes before page save

In my PageTemplates.php I have a field like this:

JavaScript

Now I would like to save also the latitude and longitude of the address they give in (if it can be found). I’ve copied the PageCrudController and changed the config in config/backpack/pagemanager.php to:

JavaScript

In my store function I have:

JavaScript

But what do I place in the if statement? How can I add (= set) an extra field to the extras field in my database?

Advertisement

Answer

Fixed it by doing the following:

Add latitude and longitude as hidden fields:

JavaScript

Set attributes by doing the following:

JavaScript

Change parent::updateCrud to parent::updateCrud($request);.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement