Re: How do i validate multiple fields using the same field name?

2012-09-16 Thread resting
Ok, finally able to get it to work.

The results if anyone is interested. 
https://github.com/resting/cakephp/commits/test_validation


On Monday, 17 September 2012 10:29:07 UTC+8, resting wrote:
>
> Hi yes, realized my mistake.
>
> Have made the changes 
> https://github.com/resting/cakephp/commit/ce2ffa4300f59720566a85db0b5ced5d4b96a117
>
> But the result is still the same...weird...
>
> On Monday, 17 September 2012 03:40:36 UTC+8, euromark wrote:
>>
>> have you ever seen validates() taking arguments? especially $data? nope
>>
>> $this->Model->set($this->request->data)
>> $result = $this->Model->validates()
>>
>> as the book describes
>>
>>
>>
>> Am Sonntag, 16. September 2012 20:09:24 UTC+2 schrieb resting:
>>>
>>> Created a test setup with v2.2.0
>>>
>>> Validation doesn't work.
>>> Empty fields still pass.
>>>
>>> What am I doing wrong here?
>>>
>>> Full source: 
>>> https://github.com/resting/cakephp/blob/test_validation/app/Controller/MyFormController.php
>>>
>>> On Friday, 14 September 2012 15:42:36 UTC+8, resting wrote:

 I have something like this in my view: 

 echo $this->Form->input('Modelname.1.fieldname');

 (ref: 
 http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#field-naming-conventions)
  


 I have this in my model: 

 public $validate = array(
 'filename' => array('ruleFilenameEmpty' => array('rule' => 
 'notEmpty', 'required' => true, 'allowEmpty' => false, 'last' => true)));

 This is the structure of $this->request->data: 

 array(
 'Capture' => array(
 (int) 0 => array(
 'filename' => '',
 )
 )
 )

 But it always return a validation error, whether there's text in the 
 textfield or not: 

 array(
 'filename' => array(
 (int) 0 => 'ruleFilenameEmpty'
 )
 )

 (printed from debug($this->Capture->validationErrors)) 

 Tested the validation with: 

 $this->Capture->set($this->request->data);
 if ($this->Capture->saveAll($this->request->data)) {
 $this->Session->setFlash('' . __('It 
 validates') . '');
 }

 I had tried all possible names for the validation. None works. 

 What am I doing wrong here? 

 Also I would like to validate each set of fields in 
 $this->request->data before saving. 

 This is because there are some others to be done after it validates.
 If the action fails, it should not save.
 This cannot be done with saveAll(). 

 How can I evaluate each set of arrays in $this->request->data before 
 saving?

>>>

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Cakephp, gearman workers and changing database connection on the fly issue

2012-09-16 Thread Ketan Shah
Thanks Tarique,

Here you go. http://pastebin.com/ezCBqyGV

On Mon, Sep 17, 2012 at 10:10 AM, Dr. Tarique Sani wrote:

> On Sat, Sep 15, 2012 at 6:46 PM, Ketan Shah  wrote:
> > Thats correct. I am sending the db config info in the workload
>
> Paste the code that you are using to change the DB
>
> This should not happen because every workload is processed in its own
> thread and they do not share anything. The DB connection should not
> get cached
>
> Tarique
>
> --
> =
> PHP for E-Biz: http://sanisoft.com
> =
>
> --
> Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>


-- 
"If you don't risk anything in life, you are risking even more"

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Cakephp, gearman workers and changing database connection on the fly issue

2012-09-16 Thread Dr. Tarique Sani
On Sat, Sep 15, 2012 at 6:46 PM, Ketan Shah  wrote:
> Thats correct. I am sending the db config info in the workload

Paste the code that you are using to change the DB

This should not happen because every workload is processed in its own
thread and they do not share anything. The DB connection should not
get cached

Tarique

-- 
=
PHP for E-Biz: http://sanisoft.com
=

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: hasMany through - how to retrieve my data?

2012-09-16 Thread Jonathan Sundquist
Why are you using a hasMany instead of a hasAndBelongsToMany? You wouldn't
need the id column as you two ideas together would be your index.

- "The cold winds are rising"
On Sep 16, 2012 5:17 PM, "Nvp"  wrote:

> Hi!
> I built DB with tables:
>
> *restaurants* - main table
>
> *kitchens* - second table
>
> *kitchen_restaurants* - join table with fields: id, kitchen_id,
> restaurant_id
>
> *Model/Restaurant.php*:
> public $hasMany = array(
> 'KitchenRestaurant'
> );
>
> *Model/Kitchen.php*:
> public $hasMany = array(
> 'KitchenRestaurant'
> );
>
> *Model/KitchenRestaurant.php*:
> public $belongsTo = array(
> 'Restaurant', 'Kitchen'
> );
>
> The problem is that I have separate controller for my main page in which I
> need to retrieve data from this models with complex conditions.
>
> I added
>
> public $uses = array('Restaurant');
>
> to my main page controller and here comes the part where I need your
> advices.
>
> I need to select only those restaurants where kitchen = $id. I've tried to
> add
> public function index() {
> $this->set('rests', $this->Restaurant->find('all', array( 'conditions' =>
> array('Restaurant.active' => "1", 'KitchenRestaurant.id' => "1") ))); }
>
> but I get Column not found error. How to properly retrieve data in hasMany
> through or HABTM?
> Thanks!
>
> --
> Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: How do i validate multiple fields using the same field name?

2012-09-16 Thread resting
Hi yes, realized my mistake.

Have made the 
changes 
https://github.com/resting/cakephp/commit/ce2ffa4300f59720566a85db0b5ced5d4b96a117

But the result is still the same...weird...

On Monday, 17 September 2012 03:40:36 UTC+8, euromark wrote:
>
> have you ever seen validates() taking arguments? especially $data? nope
>
> $this->Model->set($this->request->data)
> $result = $this->Model->validates()
>
> as the book describes
>
>
>
> Am Sonntag, 16. September 2012 20:09:24 UTC+2 schrieb resting:
>>
>> Created a test setup with v2.2.0
>>
>> Validation doesn't work.
>> Empty fields still pass.
>>
>> What am I doing wrong here?
>>
>> Full source: 
>> https://github.com/resting/cakephp/blob/test_validation/app/Controller/MyFormController.php
>>
>> On Friday, 14 September 2012 15:42:36 UTC+8, resting wrote:
>>>
>>> I have something like this in my view: 
>>>
>>> echo $this->Form->input('Modelname.1.fieldname');
>>>
>>> (ref: 
>>> http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#field-naming-conventions)
>>>  
>>>
>>>
>>> I have this in my model: 
>>>
>>> public $validate = array(
>>> 'filename' => array('ruleFilenameEmpty' => array('rule' => 
>>> 'notEmpty', 'required' => true, 'allowEmpty' => false, 'last' => true)));
>>>
>>> This is the structure of $this->request->data: 
>>>
>>> array(
>>> 'Capture' => array(
>>> (int) 0 => array(
>>> 'filename' => '',
>>> )
>>> )
>>> )
>>>
>>> But it always return a validation error, whether there's text in the 
>>> textfield or not: 
>>>
>>> array(
>>> 'filename' => array(
>>> (int) 0 => 'ruleFilenameEmpty'
>>> )
>>> )
>>>
>>> (printed from debug($this->Capture->validationErrors)) 
>>>
>>> Tested the validation with: 
>>>
>>> $this->Capture->set($this->request->data);
>>> if ($this->Capture->saveAll($this->request->data)) {
>>> $this->Session->setFlash('' . __('It 
>>> validates') . '');
>>> }
>>>
>>> I had tried all possible names for the validation. None works. 
>>>
>>> What am I doing wrong here? 
>>>
>>> Also I would like to validate each set of fields in $this->request->data 
>>> before saving. 
>>>
>>> This is because there are some others to be done after it validates.
>>> If the action fails, it should not save.
>>> This cannot be done with saveAll(). 
>>>
>>> How can I evaluate each set of arrays in $this->request->data before 
>>> saving?
>>>
>>

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




hasMany through - how to retrieve my data?

2012-09-16 Thread Nvp
Hi! 
I built DB with tables:

*restaurants* - main table

*kitchens* - second table

*kitchen_restaurants* - join table with fields: id, kitchen_id, 
restaurant_id

*Model/Restaurant.php*:
public $hasMany = array(
'KitchenRestaurant'
);

*Model/Kitchen.php*:
public $hasMany = array(
'KitchenRestaurant'
);

*Model/KitchenRestaurant.php*:
public $belongsTo = array(
'Restaurant', 'Kitchen'
);

The problem is that I have separate controller for my main page in which I 
need to retrieve data from this models with complex conditions.

I added

public $uses = array('Restaurant');

to my main page controller and here comes the part where I need your 
advices.

I need to select only those restaurants where kitchen = $id. I've tried to 
add
public function index() { 
$this->set('rests', $this->Restaurant->find('all', array( 'conditions' => 
array('Restaurant.active' => "1", 'KitchenRestaurant.id' => "1") ))); }

but I get Column not found error. How to properly retrieve data in hasMany 
through or HABTM? 
Thanks!

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Cake 2.2 Can't save/update database

2012-09-16 Thread d6games
The following code in my PlayersController doesn't error but also doesn't 
save anything to the database table...

private function authorize($tag, $pass) {
$findPlayer = $this->Player->find('first', array(
'conditions' => array('Tag' => $tag, 'Password' => $pass)
));
$playerID = 0;
if ( count($findPlayer) > 0 ) {
$playerID = $findPlayer['Player']['ID'];
$data = array('id' => $playerID, 'CurrentLogin' => date('c'));
$this->Player->save($data);
}
unset($findPlayer);
return $playerID;
}

In my table the "id" field is actually "ID", however if I change the $data 
line above to "ID", then cake switches to Insert mode and blows up. So far 
nothing I do will update the table. What am I doing wrong?

Thanks for your advice. I'm spinning my wheels...

Mark

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Find method with multiple tables

2012-09-16 Thread Ly Dara
Dear All,

Now I can solve it by using query function instead of find and use my sql
query language instead of cakephp language syntax.

However, I will post my code later because I still want to find out to use
cakephp syntax with complex find condition.

Thanks a lot for your taking time to help.

I think that it's more easy to contact me on skype my email is
lyda...@gmail.com or lydara9.

Sincerely Yours,
Dara,

On Sun, Sep 16, 2012 at 1:04 PM, Mike Griffin  wrote:

> Code, code, code, code, code. Show what you have tried.
>
> And saying something is urgent (has everything you posted been urgent?)
> won't help in most cases.
>
> --
> Mike Griffin
> Sent with Sparrow 
>
> On Sunday 16 September 2012 at 05:09, Mr. Manager wrote:
>
> Dear All,
>
> I have problem with using find method to retrieve field from many table.
>
> I have table as the following:
>
> items(id, no, name, price, discount, sample, outside)
> invoices(id, no, name, patient_id, doctor_id, source_id, discount,
> paying_date, request_date, exchange_rate, bad)
> invoice_details(id, invoice_id, item_id, price)
> sources(id, no, name, phone, address)
>
> The condition of find is about the date with $start_date, $end_date that
> should be filter in table invoices and source_id.
>
> The preferable result
> NoItem Name  Number_of_Item
> Price Total_Price
>
>
> This is urgent and I hope that anyone can help me find the solution.
>
> Thanks a lot in advance.
> Dara,
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>
>
>
>  --
> Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Find method with multiple tables

2012-09-16 Thread Mike Griffin
Code, code, code, code, code. Show what you have tried. 

And saying something is urgent (has everything you posted been urgent?) won't 
help in most cases. 

-- 
Mike Griffin
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Sunday 16 September 2012 at 05:09, Mr. Manager wrote:

> Dear All,
> 
> I have problem with using find method to retrieve field from many table.
> 
> I have table as the following:
> 
> items(id, no, name, price, discount, sample, outside)
> invoices(id, no, name, patient_id, doctor_id, source_id, discount, 
> paying_date, request_date, exchange_rate, bad)
> invoice_details(id, invoice_id, item_id, price)
> sources(id, no, name, phone, address)
> 
> The condition of find is about the date with $start_date, $end_date that 
> should be filter in table invoices and source_id.
> 
> The preferable result
> NoItem Name  Number_of_Item  
> Price Total_Price
> 
> 
> This is urgent and I hope that anyone can help me find the solution.
> 
> Thanks a lot in advance.
> Dara,
> -- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com 
> (mailto:cake-php@googlegroups.com).
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com 
> (mailto:cake-php+unsubscr...@googlegroups.com).
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>  
>  

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: How to implement the Remember Me with Auth?

2012-09-16 Thread euromark
http://www.dereuromark.de/2012/02/02/more-persistent-sessions-in-cake2-x/ 
is one easy way (only adding the component).

but since 2.x there is also some CookieAuth (i never tried before, though):
https://github.com/ceeram/Authenticate/blob/master/Controller/Component/Auth/CookieAuthenticate.php
 


Am Sonntag, 16. September 2012 16:00:51 UTC+2 schrieb tomtom:
>
> Hello,
>
> I have successfully used Auth, but unfortunately, it seems that it does 
> work only with Session. I want that if user check "Remember Me" checkbox, I 
> would use Cookie and he would be logged in for 2 weeks. I can't find 
> anything in official book and in Google I found just few and not great blog 
> posts. Is there any easy way to implement this? Thanks.
>

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: How do i validate multiple fields using the same field name?

2012-09-16 Thread euromark
have you ever seen validates() taking arguments? especially $data? nope

$this->Model->set($this->request->data)
$result = $this->Model->validates()

as the book describes



Am Sonntag, 16. September 2012 20:09:24 UTC+2 schrieb resting:
>
> Created a test setup with v2.2.0
>
> Validation doesn't work.
> Empty fields still pass.
>
> What am I doing wrong here?
>
> Full source: 
> https://github.com/resting/cakephp/blob/test_validation/app/Controller/MyFormController.php
>
> On Friday, 14 September 2012 15:42:36 UTC+8, resting wrote:
>>
>> I have something like this in my view: 
>>
>> echo $this->Form->input('Modelname.1.fieldname');
>>
>> (ref: 
>> http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#field-naming-conventions)
>>  
>>
>>
>> I have this in my model: 
>>
>> public $validate = array(
>> 'filename' => array('ruleFilenameEmpty' => array('rule' => 
>> 'notEmpty', 'required' => true, 'allowEmpty' => false, 'last' => true)));
>>
>> This is the structure of $this->request->data: 
>>
>> array(
>> 'Capture' => array(
>> (int) 0 => array(
>> 'filename' => '',
>> )
>> )
>> )
>>
>> But it always return a validation error, whether there's text in the 
>> textfield or not: 
>>
>> array(
>> 'filename' => array(
>> (int) 0 => 'ruleFilenameEmpty'
>> )
>> )
>>
>> (printed from debug($this->Capture->validationErrors)) 
>>
>> Tested the validation with: 
>>
>> $this->Capture->set($this->request->data);
>> if ($this->Capture->saveAll($this->request->data)) {
>> $this->Session->setFlash('' . __('It 
>> validates') . '');
>> }
>>
>> I had tried all possible names for the validation. None works. 
>>
>> What am I doing wrong here? 
>>
>> Also I would like to validate each set of fields in $this->request->data 
>> before saving. 
>>
>> This is because there are some others to be done after it validates.
>> If the action fails, it should not save.
>> This cannot be done with saveAll(). 
>>
>> How can I evaluate each set of arrays in $this->request->data before 
>> saving?
>>
>

-- 
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Error rendering, is it the intended functionality?

2012-09-16 Thread Léo Willian Kölln
Why there is some DB interaction during the View rendering? You dont
need to do any query "explicitly" on the View file, if you are calling
a method that does some DB interaction you are doing a Query during
the View Context.
If you need some data that comes from model (doesn't matter if it is
from DB or not), do it on the controller, setting variables to output
them on the View.

Can someone confirm my conclusion?


Léo Willian Kölln


On Sun, Sep 16, 2012 at 7:19 AM, Mohammad Naghavi  wrote:
> Hi,
> I do no query from inside the View, I just call this:
> $this->Form->create();
> inside my view. the problem is that every thing inside view before this line
> comes as a part of the exception handling output.
> what I think is that because I don't call any db or model related actions
> inside the controller, the exception is thrown and caught at the point that
> form creation is triggered, where the cake tries to connect to db.
>
> anyway I managed to solve my problem using a custom error controller. but I
> think it is good for core developers to know the situation.
>
> regards,
> MN
>
>
>
> On Fri, Sep 14, 2012 at 7:57 PM, lowpass  wrote:
>>
>> Are you making DB queries from within the View? You should be doing so
>> from the model or controller. Then, once the controller has all the
>> data it requires, it passes it to View to be rendered.
>>
>> On Fri, Sep 14, 2012 at 4:43 AM, Mohammad Naghavi 
>> wrote:
>> > Hi,
>> > I'm dealing with an action of a controller, in which no db interaction
>> > is
>> > required until it comes to rendering the view. inside the view, again
>> > first
>> > half of the view doesn't need any db interactions until a form creation
>> > is
>> > started somewhere in the middle. I'm preparing my app for production
>> > environment so I came to the point to make it clean. there I tested the
>> > situation in which DB is shut down and pointed the browser to that
>> > action,
>> > what I expected was a single internal error page, but what I got was a
>> > half
>> > rendered view, which was accompanied with the rendered error layout.
>> > something like following:
>> >
>> > 
>> > some message here
>> > 
>> >
>> >
>> > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
>> > http://www.w3.org/1999/xhtml";>
>> > 
>> >   > > />
>> >   CakePHP: the rapid development php framework:
>> >   Errors  
>> >   > > />> > href="/itbs/favicon.ico" type="image/x-icon" rel="shortcut icon" />> > rel="stylesheet" type="text/css" href="/itbs/css/cake.generic.css"
>> > />
>> > 
>> >   
>> >
>> > ...
>> >
>> >
>> > now my question is that how to remove this first part of half rendered
>> > view?
>> > I tried to set $this->response->body(' '); on beforeRender of the
>> > appController for the case that controller->name is CakeError but it
>> > didn't
>> > work, any other suggestions?
>> >
>> > regards,
>> > MN
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "CakePHP" group.
>> > To post to this group, send email to cake-php@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > cake-php+unsubscr...@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




How to implement the Remember Me with Auth?

2012-09-16 Thread tomtom
Hello,

I have successfully used Auth, but unfortunately, it seems that it does 
work only with Session. I want that if user check "Remember Me" checkbox, I 
would use Cookie and he would be logged in for 2 weeks. I can't find 
anything in official book and in Google I found just few and not great blog 
posts. Is there any easy way to implement this? Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: How do i validate multiple fields using the same field name?

2012-09-16 Thread resting
Created a test setup with v2.2.0

Validation doesn't work.
Empty fields still pass.

What am I doing wrong here?

Full 
source: 
https://github.com/resting/cakephp/blob/test_validation/app/Controller/MyFormController.php

On Friday, 14 September 2012 15:42:36 UTC+8, resting wrote:
>
> I have something like this in my view: 
>
> echo $this->Form->input('Modelname.1.fieldname');
>
> (ref: 
> http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#field-naming-conventions)
>  
>
>
> I have this in my model: 
>
> public $validate = array(
> 'filename' => array('ruleFilenameEmpty' => array('rule' => 
> 'notEmpty', 'required' => true, 'allowEmpty' => false, 'last' => true)));
>
> This is the structure of $this->request->data: 
>
> array(
> 'Capture' => array(
> (int) 0 => array(
> 'filename' => '',
> )
> )
> )
>
> But it always return a validation error, whether there's text in the 
> textfield or not: 
>
> array(
> 'filename' => array(
> (int) 0 => 'ruleFilenameEmpty'
> )
> )
>
> (printed from debug($this->Capture->validationErrors)) 
>
> Tested the validation with: 
>
> $this->Capture->set($this->request->data);
> if ($this->Capture->saveAll($this->request->data)) {
> $this->Session->setFlash('' . __('It validates') 
> . '');
> }
>
> I had tried all possible names for the validation. None works. 
>
> What am I doing wrong here? 
>
> Also I would like to validate each set of fields in $this->request->data 
> before saving. 
>
> This is because there are some others to be done after it validates.
> If the action fails, it should not save.
> This cannot be done with saveAll(). 
>
> How can I evaluate each set of arrays in $this->request->data before 
> saving?
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Error rendering, is it the intended functionality?

2012-09-16 Thread Mohammad Naghavi
Hi,
I do no query from inside the View, I just call this:
$this->Form->create();
inside my view. the problem is that every thing inside view before this
line comes as a part of the exception handling output.
what I think is that because I don't call any db or model related actions
inside the controller, the exception is thrown and caught at the point that
form creation is triggered, where the cake tries to connect to db.

anyway I managed to solve my problem using a custom error controller. but I
think it is good for core developers to know the situation.

regards,
MN



On Fri, Sep 14, 2012 at 7:57 PM, lowpass  wrote:

> Are you making DB queries from within the View? You should be doing so
> from the model or controller. Then, once the controller has all the
> data it requires, it passes it to View to be rendered.
>
> On Fri, Sep 14, 2012 at 4:43 AM, Mohammad Naghavi 
> wrote:
> > Hi,
> > I'm dealing with an action of a controller, in which no db interaction is
> > required until it comes to rendering the view. inside the view, again
> first
> > half of the view doesn't need any db interactions until a form creation
> is
> > started somewhere in the middle. I'm preparing my app for production
> > environment so I came to the point to make it clean. there I tested the
> > situation in which DB is shut down and pointed the browser to that
> action,
> > what I expected was a single internal error page, but what I got was a
> half
> > rendered view, which was accompanied with the rendered error layout.
> > something like following:
> >
> > 
> > some message here
> > 
> >
> >
> >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> > http://www.w3.org/1999/xhtml";>
> > 
> >> />
> >   CakePHP: the rapid development php framework:
> >   Errors  
> >/> > href="/itbs/favicon.ico" type="image/x-icon" rel="shortcut icon" /> > rel="stylesheet" type="text/css" href="/itbs/css/cake.generic.css"
> />
> > 
> >   
> >
> > ...
> >
> >
> > now my question is that how to remove this first part of half rendered
> view?
> > I tried to set $this->response->body(' '); on beforeRender of the
> > appController for the case that controller->name is CakeError but it
> didn't
> > work, any other suggestions?
> >
> > regards,
> > MN
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com.
> > Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Database scheme question...

2012-09-16 Thread Jeremy Burns : Class Outfit
That would do it. Then you need to set up your model associations.

public $hasOne = array(
'Manager' => array(
'className'=> 'User',
'foreignKey'   => 'manager_user_id'
),
'Contact' => array(
'className'=> 'User',
'foreignKey'   => 'contact_user_id'
)
);

On 15 Sep 2012, at 21:14, Jeff Prater  wrote:

> I'm getting started with v2.2. I'm trying to layout my database, but I'm 
> unsure how to handle the naming conventions. I have a main table, firms, 
> which stores all the companies/firms For each firm, I want to designate a 
> managing user and contact user from the users table. I need to associate a 
> specific user account from the users table. Is this the correct way to name 
> these? After reading the conventions section in the book, I'm still a little 
> confused as how to name these columns. Thanks!
> 
> firms
> -
> id
> firm_name
> manager_user_id  **
> contact_user_id  **
> 
> users
> -
> id
> user_name
> email_address
> etc.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to 
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.