CodeExtinguisher 2.0 Release Candidate 14.2 |
[eluser]Donald Hughes[/eluser]
I apologize if I've missed it somewhere else, but I had a couple of questions. 1. Is there a way to add custom validation to a CRUD form? My specific issue is having a "from" and "to" date fields and I want to add validation to ensure that the "to" field is a later date than the "from" field. 2. What is the recommended method for doing something else after the record has successfully been inserted/updated? Thank you very much for your help and for your excellent app.
[eluser]Majd Taby[/eluser]
1) Yes, look at the controllers/example.php file. It includes an example of a custom validation callback. 2) As the "temporary docs" outline, there are two ways to generate a page in CodeExtinguisher. Either using the CRUD controller (which automates basic tasks), or by writing your own controller (like the Example controller). If you use your own controller, then you can overload the execute_add or execute_edit functions to something like this: IN YOUR CONTROLLER: Code: function execute_add(){ You can do this because in CodeExtinguisher, your controllers extend CodexController, not Controller, and execute_add/execute_edit do the inserting/updating.
[eluser]Donald Hughes[/eluser]
Thanks for the quick reply! So for adding custom validation callbacks, I just do it as I would for any CI form: $rules['FIELD'] = "callback_FIELD_check"; ... function FIELD_check($str){} One other question. What if I wanted to alter the data after the user submitted the request, but before the data is inserted/edited? Thank you again!!!
[eluser]abmcr[/eluser]
A small fix in the plugin text_box: Code: $html .= ' <input class="text" type="text" value="'.stripslashes($this->value).' After [quote author="jTaby" date="1212265104"]abmcr, In your field, you can add a "table_access_restriction" which does exactly that. http://codeextinguisher.pbwiki.com/Creat...-own-pages [/quote] I have try with this code Code: $config = array( And it is possible to set a restriction acces to the table on the related field? My case is: i have a table "books" with Code: id, book.... Code: id_chapter, description.... Code: bk_cp_id,books_id,chapter_id I want to display a view with a selec as Code: SELECT preview_chapter.* And, yet, it is possible to get dinamyc the id, using a uri_segment? My idea was a code as Code: $config = array( There is a more simple way to get this goal?
[eluser]Majd Taby[/eluser]
yes, but table_access_restrictions takes an associative array, and it passes the Key as the first parameter, and the value as the second parameter to $this->db->where
[eluser]abmcr[/eluser]
Code: $config = array(
[eluser]Majd Taby[/eluser]
abmcr, here are lines 244->246 of codexcontroller.php: Code: if(count($this->table_access_restriction) > 0) As far as your query not working, I would suggest adding an "echo $this->db->last_query()" to see what is being applied and what isn't.
[eluser]Donald Hughes[/eluser]
For custom validation I get a "Message: Undefined property: News::$validation" When I try to use "$this->validation->set_message()". How do I set a custom error message? Thanks again!
[eluser]Donald Hughes[/eluser]
I figured it out. Just changed “$this->validation->set_message()”. to “$this->codexvalidation->set_message()”. |
Welcome Guest, Not a member yet? Register Sign In |