Sunday, September 21, 2014

Re: Comparable 2.xx to 3.xx functionality

Thanks, but neither seem to work...

You suggested, $allTitles = $articles->find()->extract('title');

I tried $users->find()->extract('temp_key') but gives an error of 

Call to a member function find() on a non-object


You suggested $this->User->validates(array('fieldList' => array('email', 'password')))

I tried $this->User->validates(array('fieldList' => array('email'))) but gives an error of

Unknown method "validates"

I wouldn't have thought that the second solution would have worked anyway as 3.xx seems to have done away with the use of the word array in favour of square brackets. why I don't know?

In fact, I've just found an entry on validating in controllers in 'http://book.cakephp.org/3.0/en/orm/table-objects.html' why this isn't in 'http://book.cakephp.org/3.0/en/core-libraries/validation.html', I again don't know. This seems to be a common theme with the new docs, with a lot of useful information scattered across the docs in many different places and not always where you'd expect to find it!


Dave

On Sunday, 21 September 2014 13:29:55 UTC+1, Dr. Tarique Sani wrote:

There are several ways to achieve what you want and they are all in the docs. Quoting a few lines from the V3 Book

$allTitles = $articles->find()->extract('title'); //you can add a ->where() to this 

$this->User->validates(array('fieldList' => array('email', 'password')))

Yes your controller looks just about right and it is very easy to understand what to expect as I read further. 

HTH

T



On Sun, Sep 21, 2014 at 4:23 PM, Dave Edwards <goo...@bubbletoonz.com> wrote:
Hi,

I am trying to write an app in 3.xx using functionality that I have previously used in 2.xx but despite scouring the docs, I cannot find the answers. Apologies if they are in there, but there seems to be  5x the amount of documentation especially around the new ORM.

In 2.xx I could easily find the value of a single field e.g. $this->User->field('temp_key') Is there a 3.xx equivalent ?

In 2.xx I could validate a field in a model e.g. $this->User->validates(array('fieldList' => array('email'))) Is there a 3.xx equivalent ?

Lastly a general question. The top of my Users controller currently looks like this, and I've not yet finished it...

namespace App\Controller;

use App\Controller\AppController;
use Cake\Network\Exception\ForbiddenException;
use Cake\Event\Event;
use Cake\ORM\TableRegistry;
use Cake\Utility\Security;
use Cake\ORM\Entity;

class UsersController extends AppController {

Does this look right, compared to the simplicity of 2.xx this now looks very unwieldy and complicated?

Thanks for any replies.

Dave

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
=============================================================
Hire a CakePHP dev team : http://sanisoft.com
=============================================================

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: