Feature Request #2984
Additional data to be passed with callback
| Status: | Closed | Start date: | 06/21/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % 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
History
Updated by Woody Gilk almost 3 years ago
- Target version set to v3.0.7
Updated by Ivan Kurnosov almost 3 years ago
Updated by Ivan Kurnosov almost 3 years ago
I've made 2 separated commits:
Validate class: http://github.com/zerkms/kohana-core/commit/e9422c0d500570de6b67e4607edae6ed02ce5953
Test: http://github.com/zerkms/kohana-core/commit/e8c48f1ef82f0635610d464428a2de11392925d3
Updated by Woody Gilk almost 3 years ago
- Status changed from New to Needs Test
- Assignee set to Woody Gilk
- % Done changed from 0 to 50
- Resolution set to fixed
Updated by Woody Gilk almost 3 years ago
- Status changed from Needs Test to Closed
- % Done changed from 50 to 100