Re: Layout question - adding a class to a wrapper div

2013-12-06 Thread Dave M.
Great. thanks!

On Friday, December 6, 2013 12:56:55 PM UTC-5, Leandro Machado Pereira 
wrote:
>
> I don't see any problem.
>
> I think this is normal.
>
>
> 2013/12/6 Dave M. >
>
>> I considered that approach. But what about the rest of the pages?
>> I could do something like:
>>
>> if (!isset($myWrapperClass)) {
>>  echo "";
>> } else {
>>  echo "";
>> }
>>
>> Is that too clumsy?
>>
>> On Friday, December 6, 2013 12:44:16 PM UTC-5, Leandro Machado Pereira 
>> wrote:
>>
>>> Try this.
>>>
>>> In you controller
>>> $this->set('wrapperID', $myWrapperID);
>>>
>>> In your layout
>>> echo $wrapperID;
>>>
>>> Best regards;
>>>  
>>>
>>> 2013/12/6 Dave M. 
>>>
>>>> Let's say I have a default layout containing this body 
>>>> (overly-simplified):
>>>>
>>>> 
>>>>   
>>>>
>>>>   
>>>>  
>>>>fetch('content'); ?>
>>>>  
>>>> 
>>>>
>>>> I have a need to add a class to the wrapper id for a couple of pages on 
>>>> my site.
>>>> It seems like creating a new layout is overkill for just one minor 
>>>> addition when everything inside the wrapper div is the same.
>>>>
>>>> Any ideas on how to accomplish this?
>>>>  
>>>> -- 
>>>> 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/groups/opt_out.
>>>>
>>>
>>>
>>>
>>> -- 
>>> ***Se você pretende redirecionar este e-mail, por favor, apague todos os 
>>> endereços que aparecem nele. Outra dica de segurança é endereçá-lo no Cco. 
>>> Desta forma você estará protegendo a mim, seus amigos e a você mesmo. Eu e 
>>> a Campanha Contra o SPAM agradecemos.Não envie correntes.*** 
>>>
>>  -- 
>> 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/groups/opt_out.
>>
>
>
>
> -- 
> ***Se você pretende redirecionar este e-mail, por favor, apague todos os 
> endereços que aparecem nele. Outra dica de segurança é endereçá-lo no Cco. 
> Desta forma você estará protegendo a mim, seus amigos e a você mesmo. Eu e 
> a Campanha Contra o SPAM agradecemos.Não envie correntes.*** 
>

-- 
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+unsubscr...@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/groups/opt_out.


Re: Layout question - adding a class to a wrapper div

2013-12-06 Thread Dave M.
I considered that approach. But what about the rest of the pages?
I could do something like:

if (!isset($myWrapperClass)) {
 echo "";
} else {
 echo "";
}

Is that too clumsy?

On Friday, December 6, 2013 12:44:16 PM UTC-5, Leandro Machado Pereira 
wrote:
>
> Try this.
>
> In you controller
> $this->set('wrapperID', $myWrapperID);
>
> In your layout
> echo $wrapperID;
>
> Best regards;
>
>
> 2013/12/6 Dave M. >
>
>> Let's say I have a default layout containing this body 
>> (overly-simplified):
>>
>> 
>>   
>>
>>   
>>  
>>fetch('content'); ?>
>>  
>> 
>>
>> I have a need to add a class to the wrapper id for a couple of pages on 
>> my site.
>> It seems like creating a new layout is overkill for just one minor 
>> addition when everything inside the wrapper div is the same.
>>
>> Any ideas on how to accomplish this?
>>  
>> -- 
>> 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/groups/opt_out.
>>
>
>
>
> -- 
> ***Se você pretende redirecionar este e-mail, por favor, apague todos os 
> endereços que aparecem nele. Outra dica de segurança é endereçá-lo no Cco. 
> Desta forma você estará protegendo a mim, seus amigos e a você mesmo. Eu e 
> a Campanha Contra o SPAM agradecemos.Não envie correntes.*** 
>

-- 
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+unsubscr...@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/groups/opt_out.


Layout question - adding a class to a wrapper div

2013-12-06 Thread Dave M.
Let's say I have a default layout containing this body (overly-simplified):


  
   
  
 
   fetch('content'); ?>
 


I have a need to add a class to the wrapper id for a couple of pages on my 
site.
It seems like creating a new layout is overkill for just one minor addition 
when everything inside the wrapper div is the same.

Any ideas on how to accomplish this?

-- 
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+unsubscr...@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/groups/opt_out.


Re: need help with check/uncheck all checkbox [cakephp]

2013-11-18 Thread Dave M.
I don't think the class option works for multiple checkboxes. 
What you can do is specify a div and work off of that (you can also reduce 
your js code):

 echo $this->Form->input("Country", array("options" => 
$viewData["countryList"], "multiple" => "checkbox", "onclick" => 
"resetSelectAll();" , "div" => "countries" , "name" => "selectedId")); 

 $('#selectall').click(function () {
var checked = $(this).is(':checked');
$('.countries input[type=checkbox]').each(function(){
$(this).prop('checked', checked); 
});   
});

On Friday, November 15, 2013 1:05:52 AM UTC-5, Sally wrote:
>
> I need help with this. I'm creating a checkbox to select or deselect the 
> country options. Please help to give some clues and explaination. I'll be 
> very grateful. Thanks in advance. 
> Below are the code:
>
> *Location: View/country/add.ctp file*
>
> 
> $(document).ready(function () {
> $('#selectall').click(function () {
>  var checked = $(this).is(':checked');
> 
> $('.selectedId').each(function () {
> var checkBox = $(this);
> console.debug(checkBox);
> if (checked) {
> checkBox.prop('checked', true);
> }
> else {
> checkBox.prop('checked', false);
> }
> });
> 
> });
> });
> 
> 
> Form->create('Showcase'); ?>
> 
> 
>  echo $this->Form->input('p_start', array('label' => 'Start Date'));
> echo $this->Form->input('p_end', array('label' => 'End Date'));
> echo $this->Form->input('priority', array('label' => 'Priority'));
> echo $this->Form->input('Select all Country', array("type" => 
> "checkbox", 'id'=>'selectall'));
> echo $this->Form->input("Country", array("options" => 
> $viewData["countryList"], "multiple" => "checkbox", "onclick" => 
> "resetSelectAll();" , "class" => "selectedId" , "name" => "selectedId")); 
> ?>
> 
> 
>   
>  echo $this->Form->end(__('Submit'));
> echo $this->Html->link('Back', array('action' => 'listShowcases'));
> ?>
> 
>

-- 
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+unsubscr...@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/groups/opt_out.


Re: Output to PDF with elements and styles

2013-01-23 Thread Dave M.
I had the same issue, and ended up hard-coding the full css link in the 
head of the pdf layout. 
eg. http://www.mysite.com/css/styles.css"; />
Not the most optimal solution, but it got me up and running.



On Wednesday, January 23, 2013 8:19:04 AM UTC-5, Jeremy Burns wrote:
>
> So I got Ceeram's plugin working on the server (my server admin installed 
> WKHTMLTOPDF - I still haven't got it working on my Mac) and have views 
> rendering as PDFs - top draw, very happy.
>
> Only remaining question is how to render CSS?
>
> On Tuesday, 22 January 2013 17:15:53 UTC, Jeremy Burns wrote:
>>
>> I have an existing view that I want to output to PDF. I've looked at 
>> Ceeram's plugin and dompdf but they don't hit the mark for me. The existing 
>> view is built using elements which are not pulled in and there is no CSS. 
>> Am I missing something huge here or is this just really difficult? Do I 
>> have to rebuild the view and include the raw code from the elements (which 
>> isn't very DRY) and how do I include style sheets?
>>
>> Any help or guidance is much appreciated.
>>
>

-- 
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 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 can i migrate from cakephp 1.2 to 2.x...?

2012-11-03 Thread Dave M.
1. 
http://book.cakephp.org/2.0/en/appendices/migrating-from-cakephp-1-2-to-1-3.html

2. http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html

I would definitely run through #1 just to make sure there are no deprecated 
items still in use.


On Thursday, November 1, 2012 8:07:46 AM UTC-4, Ankur Pandit wrote:
>
> is it necessary to migrate to 1.3 first from 1.2 and than to 2.x...? 
> kindly provide links or ways to help me out.
>

-- 
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 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: why cakephp doesn't support pure MVC

2012-10-15 Thread Dave M.
Also, to use the $c variable in the view, you need to set it in the 
controller:
$this->set('c', $this->M->getX());

http://book.cakephp.org/2.0/en/controllers.html#Controller::set



On Sunday, October 14, 2012 10:08:56 PM UTC-4, vinny M wrote:
>
> He's right seems like you made a mistake calling your method with the 
> wrong name :)
>
> VM 
>
> Sent from iPhone smartphone
>
> On 2012-10-14, at 9:54 PM, sutikno sofjan > 
> wrote:
>
> controller M code
>
> class M_controller extends AppController{
>
> $this->M->setM();  << This is wrong. $this->M->setX();
>
> $c = $this->M->getX();
>
>
>
> }
>
>
> On Mon, Oct 15, 2012 at 12:57 AM, Ashish Mahana 
> 
> > wrote:
>
>> if we declare a variable inside a model then we are unable to fetch its 
>> value in controller
>>
>> e.g.  
>>
>> Model M code:
>>
>> class M extends AppModel
>> {
>>var $x;
>>
>>
>> function setX(){
>> $this->x = "hello";
>> }
>> function getX(){
>> return $this->x;
>> }
>>
>> }
>>
>>
>> controller M code
>>
>> class M_controller extends AppController{
>>
>> $this->M->setM();
>>
>> $c = $this->M->getX();
>>
>>
>>
>> }
>>
>> when i check the $c in view page its blank 
>>
>> can anybody explain what is happening over here
>>
>> -- 
>> 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 post to this group, send email to cake...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> cake-php+u...@googlegroups.com .
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>  
>>  
>>
>
>  -- 
> 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 post to this group, send email to cake...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> cake-php+u...@googlegroups.com .
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>  
>  
>
>

-- 
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 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: A website for cakephp beginners

2012-10-09 Thread Dave M.
I think the problem is that instead of supplying an answer to a question 
('Be sure to add $actsAs = array('Containable); to your appModel!'), you 
instead provide a link to a blog post on your site which says 'Be sure to 
add $actsAs = array('Containable); to your appModel!'. A post which was 
created for the specific purpose of answering the specific question asked. 
It's a bit sleazy and has the appearance of spam. I mean, why would you NOT 
just say 'Be sure to add $actsAs = array('Containable); to your appModel!' 
other than an attempt to drive traffic to your site?



On Tuesday, October 9, 2012 9:23:58 AM UTC-4, Yasir Arafat wrote:
>
> I am not sure too. But I will not submit any more as they thinking it as a 
> spam.
>
> On Tue, Oct 9, 2012 at 4:27 PM, Sriram S  >wrote:
>
>> he has some nice tutorials on the site .. not sure what your problem is ?
>>
>>
>> On Monday, 8 October 2012 11:20:13 UTC+5:30, AD7six wrote:
>>>
>>> Stop spamming this group.
>>>
>>> Either ask questions, or provide answers but stop writing neither and 
>>> just linking to your blog and odesk advert. I havent seen any useful 
>>> replies from you, and I've already warned you before that your replies are 
>>> not beneficial to the community.
>>>
>>> AD
>>>
>>>  -- 
>> 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 post to this group, send email to cake...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> cake-php+u...@googlegroups.com .
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>  
>>  
>>
>
>
>
> -- 
> *Thanks & Regards.
>
> -
> Yasir Arafat (Hasib)*
> *Deputy Project Manager, *Software Solutions
> Grameen Solutions
> Contact Information:
> **
> **
> Cell : +8801816 536 901, +880197 *333* 2 888
> Web: http://arafats.info
> 
>
>  

-- 
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 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: struggling with containable - containing the same model twice

2012-10-09 Thread Dave M.
Ha. I was JUST going to ask about that!

On Tuesday, October 9, 2012 9:31:29 AM UTC-4, Greg wrote:
>
> solved it.
>
> RTFM basically :( 
>
>
> If you need to reference a model within your plugin, you need to include 
> the plugin name with the model name, separated with a dot.
>
> which seems to go for if you are referencing a model within the same 
> plugin...even though the associations don't bake like that.
>
> working now..
>
>
> On Tue, Oct 9, 2012 at 11:19 PM, Greg Skerman 
> > wrote:
>
>> oddly, if i pr($this->Operation->User) I get the structure for the User 
>> model, but if I dump out $this->Operation->OperationParticipant I get the 
>> structure for AppModel.. its almost as though OperationParticipant is not 
>> initializing?
>>
>>
>>
>> On Tue, Oct 9, 2012 at 10:44 PM, Greg Skerman 
>> > wrote:
>>
>>> Dave
>>>
>>> heres the exact OperationParticipant model:
>>>
>>> class OperationParticipant extends OperationAppModel {
>>> /**
>>>  * Validation rules
>>>
>>>  *
>>>  * @var array
>>>  */
>>> public $validate = array(
>>> 'user_id' => array(
>>> 'numeric' => array(
>>> 'rule' => array('numeric'),
>>> //'message' => 'Your custom message here',
>>> //'allowEmpty' => false,
>>> //'required' => false,
>>> //'last' => false, // Stop validation after this rule
>>> //'on' => 'create', // Limit validation to 'create' or 
>>> 'update' operations
>>> ),
>>> ),
>>> 'operation_id' => array(
>>> 'numeric' => array(
>>> 'rule' => array('numeric'),
>>> //'message' => 'Your custom message here',
>>> //'allowEmpty' => false,
>>> //'required' => false,
>>> //'last' => false, // Stop validation after this rule
>>> //'on' => 'create', // Limit validation to 'create' or 
>>> 'update' operations
>>> ),
>>> ),
>>> );
>>>
>>> //The Associations below have been created with all possible keys, 
>>> those that are not needed can be removed
>>>
>>>
>>> /**
>>>  * belongsTo associations
>>>  *
>>>  * @var array
>>>  */
>>> public $belongsTo = array(
>>> 'User' => array(
>>> 'className' => 'User',
>>> 'foreignKey' => 'user_id',
>>> 'conditions' => '',
>>> 'fields' => '',
>>> 'order' => ''
>>> ),
>>> 'Operation' => array(
>>> 'className' => 'Operation',
>>> 'foreignKey' => 'operation_id',
>>> 'conditions' => '',
>>> 'fields' => '',
>>> 'order' => '',
>>> 'counterCache' => true
>>> )
>>> );
>>> }
>>>
>>> and the Operation controller method doing the work:
>>>
>>> /**
>>>  * view method
>>>  * 
>>>  * View an operation
>>>  * 
>>>  * @param string $id
>>>  * @return void
>>>  */
>>> public function view($id = null) {
>>> $this->Operation->id = $id;
>>> if (!$this->Operation->exists()) {
>>>throw new NotFoundException(__('Invalid operation'));
>>> }
>>> $this->Operation->Behaviors->attach('Containable');
>>> $this->set('operation', $this->Operation->find('first', 
>>> array(
>>>
>>> 'contain' => array(
>>> 'User

Re: struggling with containable - containing the same model twice

2012-10-08 Thread Dave M.
I suspect there is something else going on specific to your setup. 

I baked up a quick test app and had no problems at all. I didn't alias the 
association at all.

My model names and associations were the same as yours. 

$this->Operation->find('all', array(
'contain' => array(
'User', 
'OperationType',
'OperationParticipant' => array('User')
)
);

Yielded this result:

array(
(int) 0 => array(
'Operation' => array(
'id' => '1',
'user_id' => '1',
'descr' => 'fooo',
'operation_type_id' => '1'
),
'User' => array(
'id' => '1',
'username' => 'aaa'
),
'OperationType' => array(
'id' => '1',
'descr' => 'Foo'
),
'OperationParticipant' => array(
(int) 0 => array(
'id' => '1',
'user_id' => '1',
'operation_id' => '1',
'User' => array(
'id' => '1',
'username' => 'aaa'
)
),
(int) 1 => array(
'id' => '2',
'user_id' => '2',
'operation_id' => '1',
'User' => array(
'id' => '2',
'username' => 'bbb'
)
)
)
)
)

I'm still thinking about this.

On Monday, October 8, 2012 7:45:39 AM UTC-4, José Lorenzo wrote:
>
> You need the alias as cricket said and in your find you need 'contain' => 
> array('OpUser', 'User')
>
> El lunes, 8 de octubre de 2012 01:50:05 UTC+2, Greg escribió:
>>
>> Sure have. Its containable that i'm suspecting is the problem.. Its 
>> almost as though it binds the model on the first level of contain, but then 
>> fails to rebind it after. If i turn containable off I can query the model 
>> with ->find();, but with containable on ->find() throws a non-existant 
>> method/non-existant object error.
>>
>>
>> On Mon, Oct 8, 2012 at 2:17 AM, Dave M.  wrote:
>>
>>> another wild guess: have you attached the Containable behavior?
>>>
>>> In your AppModel:
>>> public $actsAs = array('Containable');
>>>
>>> -dave
>>>
>>> On Saturday, October 6, 2012 2:58:54 AM UTC-4, Greg wrote:
>>>
>>>> Sorry to keep bumping, but this is really doing my head in...
>>>>
>>>> The only "solution" i have is to load the data without the contained 
>>>> users, and then call the users with ajax after the page has loaded - which 
>>>> seems a bit daft to me.
>>>>
>>>> On Tue, Oct 2, 2012 at 10:37 PM, Greg Skerman wrote:
>>>>
>>>>>  So even after aliasing everything, the User model appears to become 
>>>>> unbound from the OperationParticipant model and doesn't get rebound by 
>>>>> containable...
>>>>>
>>>>> anybody got any clue?
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Oct 2, 2012 at 7:54 AM, Greg Skerman wrote:
>>>>>
>>>>>> Yeah no dice :( had tried something similar to that before.
>>>>>>
>>>>>> * Model "OperationParticipant" is not associated with model "OPUser"*
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 2, 2012 at 4:05 AM, lowpass  wrote:
>>>>>>
>>>>>>> Just a wild guess: in the OperationParticipant model, try changing 
>>>>>>> the
>>>>>>> alias for User. Something like:
>>>>>>>
>>>>>>> public $belongsTo = array(
>>>>>>> 'OPUser' => array(
>>>>>>> 'className' => 'User',
>>>>>>> ...
>>>>>>>
>>>>>>> And then change the contain block to have  'OperationParticipant' =>
>>>>>>> array('OPUser')
>>>>>>>
>>>>>>> On Mon, Oct 1, 2012 at 3:05 AM, Greg Skerman  
>>>>>>> wrote:
>>>>>>> > I've been wracking my brain over this for a few hours and its 
>>>>>>> doing my head
>>>>>>> > in.
>>>>>>> >
>>>>>>> > Consider the following models and associations:
>>>>>>> >
&

Re: struggling with containable - containing the same model twice

2012-10-07 Thread Dave M.
another wild guess: have you attached the Containable behavior?

In your AppModel:
public $actsAs = array('Containable');

-dave

On Saturday, October 6, 2012 2:58:54 AM UTC-4, Greg wrote:
>
> Sorry to keep bumping, but this is really doing my head in...
>
> The only "solution" i have is to load the data without the contained 
> users, and then call the users with ajax after the page has loaded - which 
> seems a bit daft to me.
>
> On Tue, Oct 2, 2012 at 10:37 PM, Greg Skerman 
> > wrote:
>
>> So even after aliasing everything, the User model appears to become 
>> unbound from the OperationParticipant model and doesn't get rebound by 
>> containable...
>>
>> anybody got any clue?
>>
>>
>>
>> On Tue, Oct 2, 2012 at 7:54 AM, Greg Skerman 
>> > wrote:
>>
>>> Yeah no dice :( had tried something similar to that before.
>>>
>>> * Model "OperationParticipant" is not associated with model "OPUser"*
>>>
>>>
>>> On Tue, Oct 2, 2012 at 4:05 AM, lowpass 
>>> > wrote:
>>>
 Just a wild guess: in the OperationParticipant model, try changing the
 alias for User. Something like:

 public $belongsTo = array(
 'OPUser' => array(
 'className' => 'User',
 ...

 And then change the contain block to have  'OperationParticipant' =>
 array('OPUser')

 On Mon, Oct 1, 2012 at 3:05 AM, Greg Skerman 
 > 
 wrote:
 > I've been wracking my brain over this for a few hours and its doing 
 my head
 > in.
 >
 > Consider the following models and associations:
 >
 > Operation belongsTo User, OperationType and hasMany 
 OperationParticipant
 > OperationType hasMany Operation
 > OperationParticipant belongsTo User, Operation
 >
 > if I dump out the contents of OperationParticipant in the
 > OperationParticipants controller, I get exactly what I would expect - 
 a list
 > of OperationParticipants and the associated list of Users. Obviously 
 User is
 > correctly associated with OperationParticipant
 >
 > The problem comes when I want to call up an Operation and list the 
 users who
 > are participating.
 >
 > $this->Operation->find('all', array(
 >'contain' => array(
 >   'OperationType', 'User', 'OperationParticipant' => array('User')
 >   )
 >)
 > );
 >
 > I get
 >
 > Model "OperationParticipant" is not associated with model "User"
 >
 > If, from within the context of the Operations controller I do
 > pr($this->Operation->OperationParticipants->find('all'))); I get no
 > associated data back for OperationParticipants.
 >
 > Adding OperationParticipants to the $uses property yields the same 
 result,
 > no associated data.
 >
 > I've done deep contains before, and I cannot for the life of me 
 understand
 > why this is acting up.
 >
 >
 > Here are the associations:
 >
 >
 > OperationParticipant.php
 >
 > /**
 >  * belongsTo associations
 >  *
 >  * @var array
 >  */
 > public $belongsTo = array(
 > 'User' => array(
 > 'className' => 'User',
 > 'foreignKey' => 'user_id',
 > 'conditions' => '',
 > 'fields' => '',
 > 'order' => ''
 > ),
 > 'Operation' => array(
 > 'className' => 'Operation',
 > 'foreignKey' => 'operation_id',
 > 'conditions' => '',
 > 'fields' => '',
 > 'order' => '',
 > 'counterCache' => true
 > )
 > );
 >
 >
 > Operation.php
 >
 > /**
 >  * belongsTo associations
 >  *
 >  * @var array
 >  */
 > public $belongsTo = array(
 > 'OperationType' => array(
 > 'className' => 'OperationType',
 > 'foreignKey' => 'operation_type_id',
 > 'conditions' => '',
 > 'fields' => '',
 > 'order' => ''
 > ),
 > 'User' => array(
 > 'className' => 'User',
 > 'foreignKey' => 'user_id',
 > 'conditions' => '',
 > 'fields' => '',
 > 'order' => ''
 > )
 > );
 >
 > /**
 >  * hasMany associations
 >  *
 >  * @var array
 >  */
 > public $hasMany = array(
 > 'OperationParticipant' => array(
 > 'className' => 'OperationParticipant',
 > 'foreignKey' => 'operation_id',
 > 'dependent' => false,
 > 'conditions' => '',
 > 'fields' => '',
 > 'order' => '',
 > 'limit' => '',
 > 'offset' => '',
 > 'exclusive' => '',
 > 'finderQuery' => '',
 >   

Re: Cake url

2012-09-09 Thread Dave M.
look at your parentheses. 

On Saturday, September 8, 2012 1:25:43 PM UTC-4, girl wrote:
>
> thanks a lottt for reply...
> but I print 
>
> $code=$params['code']; 
>
> the problem I want to change it when if statement is true and I do 
> replacement
>
>
>

-- 
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: undefined index error

2012-08-14 Thread Dave M.
I suggest you throw a debug($weeklyroster) into your view to see how the 
array is actually structured. I would assume that you would want 
$weeklyroster[0]['Weeklyroster']['week'], 
$weeklyroster[1]['Weeklyroster']['week'], 
etc.

On Monday, August 13, 2012 11:39:37 AM UTC-4, mohit wrote:
>
> Hi Folks,
>
> I am having a strange error. I don't know what I am doing wrong.
> I am using following code in my weeklyrostercontroller.php file
>
> var $uses = array('Weeklyroster','Shift');
>>
>
> I have created a function to generate the roster.
>
>
> public function generate($id = null) {
>> $this->Weeklyroster->week= $id;
>> //if (!$this->Weeklyroster->exists()) {
>> //throw new NotFoundException(__('Invalid weeklyroster'));
>> //}
>> //$this->set('weeklyroster', $this->Weeklyroster->read('week', 
>> $id));
>> $current_roster = $this->Weeklyroster->find('all', 
>> array('conditions' => array('Weeklyroster.week' => $id)));
>> foreach ($current_roster as $current_rosters) {
>> $vid=$current_rosters['Weeklyroster']['id'];
>> 
>> $current_shifts = 
>> $this->Weeklyroster->Shift->find('all',array('conditions' => 
>> array('Shift.id' => $vid)));
>> 
>> 
>> }
>> 
>> 
>> $this->set('weeklyroster', $current_roster);
>> $this->set('current_shifts',$current_shifts);
>> 
>> }
>> }
>
>
>   if a use following code ($weeklyroster['Weeklyroster']['week'] in my 
> view file , I get the following error.
>
> *Notice* (8): Undefined index: Weeklyroster 
> [*APP\View\Weeklyrosters\generate.ctp*, line *3*]
>
> Please suggest
>
>  
>
> *With Best Regards,
> Mohit Kumar *
> *+91-9582894570*
>
>

-- 
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: Problem with multiple testAction calls with mocked Auth component - 2.2.1

2012-07-23 Thread Dave M.
I've discovered this doesn't happen when i am logged in to the app itself.
I am quite confused.

On Monday, July 23, 2012 10:58:34 AM UTC-4, Dave M. wrote:
>
> After upgrading to 2.2.1 from 2.0.x some of my controller tests are 
> failing. 
> It seems as if a mocked Auth component does not survive multiple 
> testAction calls. Am I doing something wrong here or is this expected?
>
> CandidatesControllerTest.php
> public function testExportAdmin() {
>  $Candidates = $this->generate('Candidates', array(
> 'components' => array('Auth' => array('user'))
> ));
>
> $Candidates->Auth
> ->staticExpects($this->any())
> ->method('user')
> ->with($this->equalTo('type'))
> ->will($this->returnValue('admin')); 
>
> $this->testAction('/candidates/export/active.csv');
> $this->assertEquals(2, count($this->vars['data']));
>
> $this->testAction('/candidates/export/historical.csv');
> $this->assertEquals(3, count($this->vars['data']));
> }
>
> Throwing a debug call in my CandidatesController.php 
> for $this->Auth->user('type') returns 'admin' on the first testAction, but 
> null on the second.
>
> Any ideas?
>

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Problem with multiple testAction calls with mocked Auth component - 2.2.1

2012-07-23 Thread Dave M.
After upgrading to 2.2.1 from 2.0.x some of my controller tests are 
failing. 
It seems as if a mocked Auth component does not survive multiple testAction 
calls. Am I doing something wrong here or is this expected?

CandidatesControllerTest.php
public function testExportAdmin() {
 $Candidates = $this->generate('Candidates', array(
'components' => array('Auth' => array('user'))
));

$Candidates->Auth
->staticExpects($this->any())
->method('user')
->with($this->equalTo('type'))
->will($this->returnValue('admin')); 

$this->testAction('/candidates/export/active.csv');
$this->assertEquals(2, count($this->vars['data']));

$this->testAction('/candidates/export/historical.csv');
$this->assertEquals(3, count($this->vars['data']));
}

Throwing a debug call in my CandidatesController.php 
for $this->Auth->user('type') returns 'admin' on the first testAction, but 
null on the second.

Any ideas?

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Join table issues

2007-10-12 Thread Dave M.

Hi all,
I am working on a CakePHP app where people can view and sign up for
classes (or 'meetings', as i have called them. That was the best
synonym i could think up for the reserved word of 'class').
Unfortunately, i can't change the existing database structure, so i am
trying my best to work with it. One issue i am currently having is
that the join table which houses student ids and class ids also has
other info, such as status (whether they have attended, enrolled,
dropped, etc). I've researched this a bit on this group and realize
that i can't really use the HABTM relationship because of these extra
fields. Instead, i am working on using hasMany and belongsTo.

I have reached a dead end though. Here is the stripped down set up.

--Tables---

CREATE TABLE `tbltrainees` (
  `TraineeID` varchar(11) NOT NULL,
  `FirstName` varchar(30) default NULL,
  `MiddleName` varchar(20) default NULL,
  `LastName` varchar(30) default NULL,
  PRIMARY KEY  (`TraineeID`),
);

CREATE TABLE `tblclasses` (
  `ClassID` varchar(15) NOT NULL,
  `ClassTitle` varchar(50) default NULL,
  PRIMARY KEY  (`ClassID`),
) ;

CREATE TABLE `tbltraineesclasses` (
  `ID` int(6) NOT NULL auto_increment,
  `ClassID` varchar(50) NOT NULL,
  `TraineeID` varchar(50) NOT NULL,
  `TraineeStatus` int(10) NOT NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ClassID_2` (`ClassID`,`TraineeID`),
) ;


---Models---


class Trainee extends AppModel
{
var $name = 'Trainee';
var $tablePrefix = 'tbl';
var $primaryKey = 'TraineeID';

var $hasMany = array(
 
'Enrollment'=>array('className'=>'Enrollment','foreignKey'=>'TraineeID')
);
}


class Meeting extends AppModel
{
var $name = 'Meeting';
var $useTable = 'tblclasses';
var $primaryKey = 'ClassID';

var $belongsTo = array(
 
'Room'=>array('className'=>'Room','foreignKey'=>'RoomID'),
'Course'=>array('className' => 'Course','foreignKey'
=> 'CourseID'),
);

var $hasMany = array(
 
'Enrollment'=>array('className'=>'Enrollment','foreignKey'=>'ClassID')
 );
}


class Enrollment extends AppModel
{
var $name = 'Enrollment';
var $useTable = 'tbltraineesclasses';
var $primaryKey = 'ID';

var $belongsTo = array(
'Trainee' =>
array('className'=>'Trainee','foreignKey'=>'TraineeID'),
'Meeting' =>
array('className'=>'Meeting','foreignKey'=>'ClassID'),
'TraineeStatus' =>
array('className'=>'TraineeStatus','foreignKey'=>'StatusID')
);
}

(i haven't included the trainee status,room and course table info/
models for sake of brevity)

My issue is that when i look at '/trainees/view/1234', there are two
queries performed - the select for the Trainee, and the related select
for the Enrollment records for that Trainee ID. I can't seem to then
get the related Meeting data for each of those Enrollments. Also, the
related TraineeStatus records are not returned either.

Is there something obvious i am doing wrong here?

On a larger note, is there a better way to do all of this? I just saw
something about using a finderQuery instead. Should I try that?

thanks!
-dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Loop through records in Model and update records

2007-07-07 Thread Dave M.

thanks grant.
i guess the findby name function doesn't work how i thought it did. i
used findAll instead and, along with your suggestion for $this->id=
$row['Modelname']['id'] everything seems to work well. updateAll()
seems like an even better solution, but i can't seem to get it to
work. i get an sql error from cake. i tried rooting around in the API
for information about updateAll but can't find anything.

thanks again,
dave


On Jul 6, 4:58 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> 1.  Use updateAll()
> $this->updateAll( array('printed'=>'Y'), array('printed'=>'N') );
>
> 2.  Are you sure that "findByPrinted" will return an array of data
> without your model key?  I would have thought you want
>
> function updatePrintStatus(){
> $ret = $this->findByPrinted('N');
> foreach($ret as $row){
> $this->id = $row['YourModel']['id'];
> $this->save(array('printed'=>'Y'));
> }
>
> }
>
> 3.  If that doesn't work, try saving with the id too
> $this->save(array('printed'=>'Y','id'=>$row['YourModel']['id']));
>
> On Jul 7, 6:42 am, "Dave M." <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
> > For some reason I cannot get this to work, but I know there is
> > something simple I am overlooking.
>
> > I have a function in my model which should find all records with a
> > certain criteria (in this case, those records whose 'printed' field is
> > 'N') and then update those records (changing 'printed' to 'Y'). The
> > code I have been trying is below. What is happening is that only the
> > first record is updated. I though unsetting the id would solve that
> > problem, but it does not.
>
> > function updatePrintStatus(){
> > $ret = $this->findByPrinted('N');
> > foreach($ret as $row){
> > $this->id = $row['id'];
> > $this->save(array('printed'=>'Y'));
> > unset($this->id);
> > }
>
> > }
>
> > Any thoughts?
>
> > thanks,
> > dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Loop through records in Model and update records

2007-07-06 Thread Dave M.

Hi all,
For some reason I cannot get this to work, but I know there is
something simple I am overlooking.

I have a function in my model which should find all records with a
certain criteria (in this case, those records whose 'printed' field is
'N') and then update those records (changing 'printed' to 'Y'). The
code I have been trying is below. What is happening is that only the
first record is updated. I though unsetting the id would solve that
problem, but it does not.

function updatePrintStatus(){
$ret = $this->findByPrinted('N');
foreach($ret as $row){
$this->id = $row['id'];
$this->save(array('printed'=>'Y'));
unset($this->id);
}

}

Any thoughts?

thanks,
dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---