|
|
Sorry, everything is cached either in memory (Memcache) or plain file
depending on the data pulled. I was just wondering if it made sense to ask
for the same data twice in the same action (once for the view and again for
validation) in these cases.
K
-----Original Message-----
From: cake-php@xxxxxxxxxxxxxxxx [mailto:cake-php@xxxxxxxxxxxxxxxx] On Behalf
Of John Andersen
Sent: Sunday, February 20, 2011 10:06 AM
To: CakePHP
Subject: Re: Variables for Validation
I would look into using the cache! Start from here in the CakePHP
book:
http://book.cakephp.org/view/1193/Caching
Enjoy,
John
On Feb 20, 2:22 pm, "Krissy Masters" <naked.cake.ba...@xxxxxxxxx>
wrote:
> Not sure why I only thought of this now.
>
> Any form: quick dummy function
>
> function edit() {
>
> If(!empty($this->data)) {
>
> If($this->save());
>
> // whatever
> }
> $countries = $this->Model->_getCountries(); // returns list of countries
> $this->set(compact('countries'));
>
> }
>
> So you have a full list of countries in the form user can select from.
>
> $validate array() in model I have a function to check the country_id value
> and that function also uses _getCountries();
>
> public function checkCountryValues( $data, $field ){
>
> $valid = false;
> if( !empty( $this->data[$this->alias][$field] ) ) {
> if ( array_key_exists($this->data[$this->alias][$field],
> $this->_getCountries() ) ){
> $valid = true;
> }
> }
> return $valid;
>
> }
>
> So I am essentially grabbing that data twice. How can I reuse that initial
> $countries throughout the whole process rather than grabbing the same data
> over and over?
> Might sounds trivial but some models might have 6 or more related models
and
> then validating pulling all the same values used in the view / form it is
> just added work.
>
> Thanks,
> K
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at
http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at
http://groups.google.com/group/cake-php
|
|