Saturday, March 27, 2010

Re: Undefined index

I'm finding that the 'Auth' component is removing 'password' and 'username' from the data array for security purposes. This poses a problem if I want to access that data via Js/Ajax before the form actually submits. Renaming those fields bypasses this problem but it also creates a ripple affect and causes issues elsewhere making it necessary to jump through even more hoops and re-write other actions to handle the changes. I suppose it's not absolutely necessary to have access to the data in these fields before the form is submitted and I could just as easily let Cake do what it wants but what fun is that ? Do I really want to put myself at the mercy of a framework and give up full control for the sake of simplicity ? Understandably, I just started with Cake so perhaps through ignorance alone I may inadvertently be making some things a bit more difficult then they need to be but this is just a simple registration form ... how much of a beating am I in for somewhere down the road when I try to get cake to handle the back end of a Flex App? 

While I'm finding some of Cake's functionality very appealing and worth the time it takes to learn, is it truly worth it? I've spent years adding to and refining my own functions library and while it's certainly not "automagic" it's just as effortless to implement even the most complex functions. A properly created database will be set up with PK's, FK's, indexes, triggers, functions, etc.  making data management a breeze and not at all as complicated as some people make it. Custom queries, views, events, stored procedures, schemas, sql dumps, etc. are only a click away. A smart database design will allow the database to do the bulk of the work for you with minimal input from your app. I've seen queries that would make your head spin and it really doesn't need to be that way.  So my question now is that while a framework may not be the right choice for some, what is the biggest benefit Cake has to offer me? 

On Sat, Mar 27, 2010 at 4:29 AM, Ed Propsner <crotchfrog@gmail.com> wrote:
Am I missing something here with the way Cake handles password fields ?? 

I ended up just writing my own js function to pull the values I wanted from the form and pass them into the controller. Oddly enough it still wouldn't recognize the password field ... well not so much that it wasn't being recognized but the script was seeing the form field as empty. Out of curiosity I changed the name of the password field from "User.password" to just "pw" and the issue went away. I was then able to run the script with both field values. Thinking maybe there was a typo in the original syntax I scripted that form field again with it's original name of "User.password" and the problem immediately came back.  

On Sat, Mar 27, 2010 at 2:23 AM, Jeremy Burns <jeremyburns@me.com> wrote:
I'm no Ajax expert, but that sounds about right!


Jeremy Burns

On 27 Mar 2010, at 06:22, Ed Propsner wrote:

I think part of the problem here is that $ajax->observeField is only is only focusing on a single form field and that is the element being passed to the controller. I just assumed Any/all of my form data was accessible in any one of the controllers. 



On Sat, Mar 27, 2010 at 1:48 AM, Ed Propsner <crotchfrog@gmail.com> wrote:
Sorry, I'm new to Cake and was a bit confused. I was echoing the debug inside the controller that the ajax call uses. The only two fields that are being used in that controller are 'password' and 'confirm_password' ... only 'confirm_password' is displayed with the debug. 

Up until now I never thought to try to run the debug in the add() controller and when I did the entire form was in fact displayed in the array. 

Now I'm just plain confused ;)


On Sat, Mar 27, 2010 at 1:32 AM, Jeremy Burns <jeremyburns@me.com> wrote:
You say they are being recognised OK, but they weren't in the $this->data array?

Have you checked the actuail page source to examine the form in the view? Only yesterday I debugged a similar problem where the browser was ending the form for me (I had embedded it incorrectly into a table).


Jeremy Burns


On 27 Mar 2010, at 05:28, Ed Propsner wrote:

Yup, I double checked to make sure I didn't somehow inadvertently end the form early but it's all good. The field before 'password' is 'username' and i'm using $ajax->observeField to display changes to the 'username' field but it's not doing anything and I'm guessing that it's' not seeing the field for whatever reason. The are several more fields below username and password and they are being recognized okay. 

On Sat, Mar 27, 2010 at 1:18 AM, Jeremy Burns <jeremyburns@me.com> wrote:
But are they inside the form in the view?


Jeremy Burns

On 27 Mar 2010, at 05:15, Ed Propsner wrote:

Yes, I'm expecting to see $this->data['User'][''password'] as well. Both fields exist and are displayed in the view. 

On Sat, Mar 27, 2010 at 1:09 AM, Jeremy Burns <jeremyburns@me.com> wrote:
So all you can get is $this->data['User']['confirm_password']...

Are you expecting more fields to be in the array? Are the fields you want inside the form in the view?


Jeremy Burns


On 27 Mar 2010, at 05:00, Ed Propsner wrote:

The only thing showing in the array is the field for 'confirm_password',

[code]

 Array (     [User] => Array         (             [confirm_password] => test         )  )
[/code]
 I'm having the same issue with the the username field. It's acting like the field doesn't exist. 

On Sat, Mar 27, 2010 at 12:54 AM, Jeremy Burns <jeremyburns@me.com> wrote:
The reason I recommended that you examine the data array is that sometimes (and I often get confused with this myself) you need to double check exactly where the item you are looking for sits in the array. So if you can see the field you want, build the path to it by walking back up from it. If the path is not right, you get the undefined index error. Is it worth pasting the output here?


Jeremy Burns


On 27 Mar 2010, at 02:59, Ed Propsner wrote:

I'm not sure why but I'm relatively sure that it's not recognizing the form fields for username and password. 

On Fri, Mar 26, 2010 at 10:38 PM, Ed Propsner <crotchfrog@gmail.com> wrote:
Yes, I did try that. There is a field for confirm password as well and that is all that is being presented to the controller. 


On Fri, Mar 26, 2010 at 1:29 AM, Jeremy Burns <jeremyburns@me.com> wrote:
Have you debugged the data that is being presented to the controller function? Set debug to 2 and type die(debug($this->data)); as the first instruction, then take a look at what you see. Is password there? You might need to do something like $this->data[0]['password'], for example.

Jeremy Burns


On 25 Mar 2010, at 22:01, Ed Propsner wrote:

I'm still goofing with forms, ajax, validation, etc. trying to learn Cake. 

I have a form set up with a field for password    [code]   $form->input('User.password');   [/code]

When I reference that field in the controller [code]   $pw1 = $this->data['User']['password'];    [/code]

I keep getting "undefined index for password." It looks okay, what else could be the issue ? 

Also, I thought I had the ajax helper figured out for the most part but there is still one field that just refuses to cooperate. 

[code]

echo $html->tableCells(array('Username:', $form->input('User.username', array('label' => '')), '<div id="nameAvail"></div>'));
echo $ajax->observeField('UserUsername', array('url' => 'checkUsername', 'update' => 'nameAvail'));

[/code]

- Ed 





Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.



Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.



Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
 
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: