This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.0 » Stumped on validation (getting "Array to string conversion" notice)
Stumped on validation (getting "Array to string conversion" notice) [message #20202] Tue, 23 January 2007 03:44 Go to next message
prometheas  is currently offline prometheas
Messages: 9
Registered: January 2007
Location: Brooklyn, NY USA
Junior Member
Hi everyone!

I'm having a difficult time figuring out what's going wrong with my validation settings. I've tried adding an sfCompareValidator to a field, and I'm getting the following error, repeated before EVERY text input on the edit form:

Quote:

Notice: Array to string conversion in /usr/local/php5/lib/php/symfony/util/sfToolkit.class.php on line 329


Here's what my edit.yml validation file looks like:


methods:
    post:
        - "customer_profile{email}"
        - "customer_profile{new_password}"
        - "customer_profile{new_password_confirm}"

names:
    
    customer_profile{email}:
        required : yes
        message  : Customer profiles must define an email address
        
    customer_profile{new_password}:
        required : no
        group    : password
        
    customer_profile{new_password_confirm}:
        required : no
        group    : password
        sfCompareValidator:
            check: "customer_profile{new_password}"
            compare_error: The password confirmation does not match the password. Please try again.
        


For what it's worth, the form was created by an admin generator, and it's part of the edit action.

Tangentially, the docs covering validation seem a little out-of-date. I attempted following the examples in there for another form, and Symfony complained about my omitting the "required" parameter.

Any guidance would be tremendously appreciated!



Best,
jL
Re: Stumped on validation (getting "Array to string conversion" notice) [message #20214 is a reply to message #20202 ] Tue, 23 January 2007 09:34 Go to previous messageGo to next message
vinilios  is currently offline vinilios
Messages: 89
Registered: February 2006
Location: Athens
Member

i think the problem is this line

            check: "customer_profile{new_password}"


give it a try and remove the double quotes :/
Re: Stumped on validation (getting "Array to string conversion" notice) [message #20254 is a reply to message #20214 ] Tue, 23 January 2007 16:24 Go to previous messageGo to next message
prometheas  is currently offline prometheas
Messages: 9
Registered: January 2007
Location: Brooklyn, NY USA
Junior Member
I'll give that a shot, when I get back to my computer, though I should note that it works w/o any notices on Beta 3, but not Beta 4...

Some time after posting the question, I had to just go ahead and deploy the update from my dev box (where I was getting the notices, and running Beta 4) to the staging server, so my client could review the rest of the progress.

After deploying to the staging server (again, running Beta 3), the notices vanished.

This may also have something to do with the fact that there seem to be "fixes" to yaml parsing between releases, though I can't be certain.

Anyhow, I shall definitely give your suggestion a go!



Na'se kalla, fille! Wink

jL
Re: Stumped on validation (getting "Array to string conversion" notice) [message #20294 is a reply to message #20214 ] Wed, 24 January 2007 07:15 Go to previous messageGo to next message
prometheas  is currently offline prometheas
Messages: 9
Registered: January 2007
Location: Brooklyn, NY USA
Junior Member
OK, so I tried removing the quotes, as suggested, and this is the result:


Quote:

Fatal error: Unsupported operand types in /usr/local/php5/lib/php/symfony/util/Spyc.class.php on line 667



Smile



jL
Re: Stumped on validation (getting "Array to string conversion" notice) [message #20343 is a reply to message #20254 ] Wed, 24 January 2007 15:52 Go to previous messageGo to next message
vinilios  is currently offline vinilios
Messages: 89
Registered: February 2006
Location: Athens
Member

prometheas wrote on Tue, 23 January 2007 16:24


This may also have something to do with the fact that there seem to be "fixes" to yaml parsing between releases, though I can't be certain.



probably you're right.
Re: Stumped on validation (getting "Array to string conversion" notice) [message #20369 is a reply to message #20343 ] Thu, 25 January 2007 02:45 Go to previous messageGo to next message
prometheas  is currently offline prometheas
Messages: 9
Registered: January 2007
Location: Brooklyn, NY USA
Junior Member
Heh... yes... so I take it that the validation seems otherwise ok. Maybe there's a bug worth filing in here..... Smile
SOLVED -- Symfony validation docs were actually wrong [message #20492 is a reply to message #20202 ] Mon, 29 January 2007 01:39 Go to previous messageGo to next message
prometheas  is currently offline prometheas
Messages: 9
Registered: January 2007
Location: Brooklyn, NY USA
Junior Member
OK gang... the Symfony docs about the sfCompareValidator are wrong.

Well, that's half-accurate... actually, as it turns out, the 0.6.3 version of the validation documentation has the CORRECT solution... which is funny largely because i'm using 1.0beta4.

Anyhow, just wanted to put that out there, in case anyone else ran into this issue.



jL
Re: SOLVED -- Symfony validation docs were actually wrong [message #23074 is a reply to message #20492 ] Tue, 06 March 2007 02:52 Go to previous messageGo to next message
mhfs  is currently offline mhfs
Messages: 7
Registered: May 2006
Junior Member
guys ..

Im having the same problem ..

What is the solution .. its not clear to me ..

Thanks,
Marcelo
Re: SOLVED -- Symfony validation docs were actually wrong [message #27012 is a reply to message #23074 ] Wed, 09 May 2007 23:57 Go to previous messageGo to next message
prometheas  is currently offline prometheas
Messages: 9
Registered: January 2007
Location: Brooklyn, NY USA
Junior Member
OH... was using a client-side validation plugin... and THAT was what was choking on the validation yaml files (using the 'old' 0.6 format).

Sorry I'm responding so late, btw...
Re: Stumped on validation (getting "Array to string conversion" notice) [message #42347 is a reply to message #20202 ] Wed, 26 December 2007 08:30 Go to previous messageGo to next message
lionslair  is currently offline lionslair
Messages: 89
Registered: October 2007
Location: Perth / Western Australia
Member
I have this same issue but no quotes. only shows in development mode.

methods: 
  post: [employee, sendername, senderemail, messageBody]

names:
  employee:
    required: true
      required_msg: Please, select an employee to email
    sfNumberValidator:
      min: 1
      min_error: Please, select an employee to email
  
  sendername:
    required: true
      required_msg: Please, enter your name
    validators: nValidator
    
  messageBody:
    required: true
      required_msg: This field needs to be correctly completed else why are you sending an email
    validators: msgValidator
       
  senderemail:
    required: true
      required_msg: A valid email address is required
    validators: emailValidator
    
nValidator:
  class: sfStringValidator
  param:
    min: 2
    min_error: Please enter your real name
    
msgValidator:
  class: sfStringValidator
  param:
    min: 6
    min_error: Please, enter the real message you wish to send
    
    
emailValidator:
  class: sfEmailValidator
    strict:       true
    email_error:  This email address is invalid

[Updated on: Wed, 26 December 2007 10:41]


www.lionslair.net.au
Re: Stumped on validation (getting "Array to string conversion" notice) [message #42356 is a reply to message #20202 ] Wed, 26 December 2007 11:45 Go to previous messageGo to next message
lionslair  is currently offline lionslair
Messages: 89
Registered: October 2007
Location: Perth / Western Australia
Member
Not solved but close to it. I just need to get the employeeid field to validate.

fields:
  employeeid:
    required:
      msg: Please, select an employee to email
    sfNumberValidator:
      min: 100
      min_error: Please select an employee to email 
  
  sendername:
    required: 
      msg: Please, enter your name
    sfStringValidator:
      min: 2
      min_error: Please enter your real name 
       
  senderemail:
    required:
      msg: A valid email address is required
    sfEmailValidator:
      strict:       true
      email_error:  This email address is invalid
      
  messageBody:
    required:
      msg: This field needs to be correctly completed else why are you sending an email
    sfStringValidator:
      min: 6
      min_error: Please, enter the real message you wish to send

[Updated on: Wed, 26 December 2007 13:11]


www.lionslair.net.au
Re: Stumped on validation (getting "Array to string conversion" notice) [message #43586 is a reply to message #42347 ] Thu, 17 January 2008 14:00 Go to previous messageGo to next message
satya61229  is currently offline satya61229
Messages: 48
Registered: December 2007
Location: Bangalore, India
Member
It seems, all u need to align the required_msg: with required:


-
regards
Satya
Re: Stumped on validation (getting "Array to string conversion" notice) [message #51102 is a reply to message #20202 ] Wed, 30 April 2008 03:00 Go to previous messageGo to next message
stigm  is currently offline stigm
Messages: 1
Registered: April 2008
Location: Melbourne, Australia
Junior Member
If anyone else is having trouble adding a sfCompareValidator to an admin generator page, more specifically to compare a password, the following worked for me:

In my generator.yml file:

display:  [password, _password_validate]


Note the partial _password_validate, which means you create a partial to contain the password_validate input box:

<input type="password" id="user_password_validate" name="user[password_validate]" size="50">


Now in the validation (edit.yml):
  cms_user{password_validate}:
    required:
      msg:      Please retype the password.
    sfCompareValidator:
      check:    "user[password]"
      compare_error: The two passwords do not match.


Note the "user[password]" normally you would use "user{password}" but this does not work for the check!

If you get any 'User::setPasswordValidate()' function not exists errors, just create a dummy setPasswordValidate() function on your User.class.php model file.

-Stig

[Updated on: Wed, 30 April 2008 03:20]

Re: Stumped on validation (getting "Array to string conversion" notice) [message #101290 is a reply to message #51102 ] Mon, 21 June 2010 08:45 Go to previous message
vpriya07g  is currently offline vpriya07g
Messages: 1
Registered: June 2010
Junior Member
Thanks for the advice
user[password] worked for the check
Previous Topic:Saving form data to the database
Next Topic:Can't remove prototype from <head>
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software