Feature Request #2984

Additional data to be passed with callback

Added by Ivan Kurnosov over 4 years ago. Updated over 4 years ago.

Status:ClosedStart date:06/21/2010
Priority:NormalDue date:
Assignee:Woody Gilk% Done:

100%

Category:Core
Target version:v3.0.7
Resolution:fixed Points:

Description

I think that validate::callback() should accept 3 parameters (field, callback and additional data) as well as validate::rule()

Relevant irc-talk from #kohana

[19:16:06] <Goose1984> How do I pass extra variables in a validation callback
[19:17:05] <rafsoaken> Goose1984: don't you put them just in the array after the callback string?
[19:18:59] <Goose1984> tried that and I get Unknown Exception: validation.not_callable
[19:21:19] <zerkms> rafsoaken: callback doesn't accept additional info
[19:21:23] <zerkms> Goose1984: you cannot
[19:22:16] <rafsoaken> zerkms: is that by design?
[19:22:25] <zerkms> rafsoaken: it is by implementation ;-)
[19:22:29] <zerkms> public function callback($field, $callback)
[19:22:30] <Goose1984> so is the only way to set like a session and then clear it
[19:22:43] <zerkms> Goose1984: what are you trying to do?
[19:23:58] <Goose1984> Check to see if the email address exists in the db
[19:24:16] <Goose1984> but when I edit the record I want it to exclude the current id
[19:24:42] <zerkms> did current_id passed inside validated array?
[19:24:49] <Goose1984> so select email from users where email = '[email protected]' and user_id != 2
[19:25:05] <zerkms> ?
[19:25:12] <Goose1984> No
[19:25:27] <zerkms> then i propose you to add it there ;-)
[19:25:43] <zerkms> after you added it to validated array - you can access it inside callback function
[19:28:59] <Goose1984> ok thanks

Related issues

Related to Kohana v3.x - Bug Report #3185: Modify Validate::callbacks to take parameters Closed 08/15/2010

History

#1 Updated by Woody Gilk over 4 years ago

  • Target version set to v3.0.7

#4 Updated by Woody Gilk over 4 years ago

  • Status changed from New to Needs Test
  • Assignee set to Woody Gilk
  • % Done changed from 0 to 50
  • Resolution set to fixed

#5 Updated by Woody Gilk over 4 years ago

  • Status changed from Needs Test to Closed
  • % Done changed from 50 to 100

Also available in: Atom PDF