difference between $this-data and $this-set('data')
hi, Can someone can tell me the difference between using $this- set('data', array()) and $this-data in controller. I am especially getting confused about this in relation to form. In general to send data to view, we have to set the variable using $this- set(data, array). But to set the form, we need to use $this-data bingo. --~--~-~--~~~---~--~~ 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: difference between $this-data and $this-set('data')
$this-set('yourvar', $somedata) will create a variable called $yourvar in the view, with the passed data. $this-data is model data that is from/for a form - all of the FormHelper functions look at $this-data to prepopulate from, and all the data they submit comes into your controller under $this-data. So basically, you should not have $this-set( 'data', $something ), because it becomes confusing having a $data variable and $this-data, which are quite different in scope and usage. --~--~-~--~~~---~--~~ 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: difference between $this-data and $this-set('data')
And in case you weren't aware - you can access $this-data directly in both the view and the controller. So in your view you can have something like: h2Change password for `?php echo $this-data['User']['name']; ? / h2 ?php echo $form-input('User.password'); ? and both parts here will access the same user object, from $this- data['User'] in the controller. --~--~-~--~~~---~--~~ 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: difference between $this-data and $this-set('data')
$this-set('data', array()) will make $data available in your view. That means, you can write something like echo $data; in your view file. On the other hand, $this-data contains submitted data from your form. On Jul 1, 3:22 am, bingo [EMAIL PROTECTED] wrote: hi, Can someone can tell me the difference between using $this-set('data', array()) and $this-data in controller. I am especially getting confused about this in relation to form. In general to send data to view, we have to set the variable using $this- set(data, array). But to set the form, we need to use $this-data bingo. On Jul 1, 3:22 am, bingo [EMAIL PROTECTED] wrote: hi, Can someone can tell me the difference between using $this-set('data', array()) and $this-data in controller. I am especially getting confused about this in relation to form. In general to send data to view, we have to set the variable using $this- set(data, array). But to set the form, we need to use $this-data bingo. --~--~-~--~~~---~--~~ 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: difference between $this-data and $this-set('data')
$this-set('data', array()) will make $data available in your view. That means, you can write something like echo $data; in your view file. On the other hands, $this-data contains submitted data from your form. On Jul 1, 3:22 am, bingo [EMAIL PROTECTED] wrote: hi, Can someone can tell me the difference between using $this-set('data', array()) and $this-data in controller. I am especially getting confused about this in relation to form. In general to send data to view, we have to set the variable using $this- set(data, array). But to set the form, we need to use $this-data bingo. --~--~-~--~~~---~--~~ 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: difference between $this-data and $this-set('data')
$this-data is also available in your view in Cake 1.2. It is a copy of $this-data that is in the controller. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---