CakePHP 3 Tutorial 19: Display One Thing, Save Another

Submitted by naidim on Tue, 10/25/2016 - 13:37

There may come a case, as in the previous tutorial (CakePHP 3 Tutorial 18: Autocomplete) that you want to display one thing in a form field, yet save a different value. In the previous case, you select a user's name from an autocomplete list, yet the user's id is the value you want to save in the database.

CakePHP 3 Tutorial 17: Adding Associated Records

Submitted by naidim on Tue, 10/25/2016 - 11:42

In the previous tutorial (CakePHP 3 Tutorial 16: Table Relationships) we set up associating tables and displaying associated data, but there's no point to displaying associated data if you can't add it first.

There are multiple ways to save associated data. We'll start with the easiest way first.

CakePHP 3 Tutorial 15: Neighbors

Submitted by naidim on Tue, 10/18/2016 - 07:58

In CakePHP 2 there was a handy feature called "neighbors" where you could simply request the neighboring records (previous and next) for easy linking. This is not present in CakePHP 3, probably due to the limited use of such a feature, however, with custom finders you can replicate the functionality.

In your model (e.g. src/Models/Table/UsersTable.php) add the following custom finder: