Welcome Guest, Not a member yet? Register   Sign In
Validate a page alias requires more than 1 callback
#1

[eluser]gh0st[/eluser]
Hi, I'm trying to write a simple form which has a "title", "page alias" and a "body".

I need to validate the page alias for the following callbacks, but am having issues (explained below);

Validation rules;
1. If its an "add" action, it must generate a "page alias" from the "title". Go to 3.
2. If its an "edit" action, no generation must happen. Go to 4.

3. If its an "add" action:
+ Ensure the "page alias" is unique against MySQL.

4. If its an "edit" action:
+ Ensure the "page alias" is unique, but use the ID of the "edit" to add to a MySQL filter

Here's the problem.

1. Firstly, I don't know how to have multiple callbacks.

2. Secondly, I don't know how to pass the ID and the ACTION into a callback.

3. When calling the set_rules (shown below), the ID, ACTION or other variables may not even exist, or be invalid -- so how does the form validator handle this?

4. It must ignore the form validation rule if the "page alias" is relating to this record.

Code:
// callback to check the action
$this->form_validation->set_rules('action', 'Action', "trim|required|callback__check_action");

// callback to check the page alias -- but I need to feed it the ID, and the ACTION (assuming both exist)
$this->form_validation->set_rules('pageAlias', 'Page Alias', "trim|callback___check_page_alias");




Theme © iAndrew 2016 - Forum software by © MyBB