DMZ 1.7.1 (DataMapper OverZealous Edition) |
[eluser]OverZealous[/eluser]
@CEmy I think the DB error is pretty clear: you are trying to sort on a column that does not exist. Is your column mislabeled in your code or in the database? DMZ is generating exactly the code you requested.
[eluser]tomdelonge[/eluser]
For some reason, I honestly can't get my head around "self relationships". I looked at the bug model in the example application, along with the model in the advanced relationships section of the DMZ userguide. I imagine that each category "has one" parent and "has many" children. I honestly don't know what to setup for a table and how I would setup a query to find each category and it's children. I don't understand what to put for "other_field" and such. Quite frankly, I don't really know how to even start with this. Any tips? (Like I said, I looked over the user guide, I just can't figure this out)
[eluser]OverZealous[/eluser]
@tomdelonge A self relationship is just a named relationship. Do you understand how multiple relationships to the same object work? IE: the creater/editor relationship from Bug to User? For self relationships, you are just relating one object to itself. Remember, all relationships have to be described from both sides. other_field literally is just the name of the other (opposite) field in the relationship. Notice in the example below how the relationship key and other_field are just swapped between the two definitions. Here's some (untested) code: Code: class Category extends DataMapper { You only need the categories table: Code: categories Usage: Code: $root = new Category(1); It's really that simple, especially for $has_one self relationships. Feel free to choose better (shorter) names. ---------- One more option, you can use a simpler relationship name on one side of the relationship, like so: Code: $has_one = array('category' => array('other_field' => 'child')); But that can be confusing. Who says I don't have time to answer questions? ![]()
[eluser]Alface[/eluser]
I Extend the DataMapper Directly for fix the validation rule "file_required", because DMZ use the CI function for to it, and it can't handdle it, and then I used an "Form Validation extention with File for Code Igniter": Forum: http://ellislab.com/forums/viewthread/123816/ Site: http://devbro.com/testing/ci_form_validation/ And to do this I I extended the function validate with is not possible extend on DMZ 1.71 because it is private. I just changed line 1508 of application/libraries/datamapper.php Code: if ( ! $related && ! in_array('required', $rules)) Code: if ( ! $related && ! in_array('required', $rules)&& ! in_array('file_required', $rules)) // Mod file_required :: I think we should implement it on this version of DMZ, dont you think? If don't think so, how could I make DMZ use this mod and not CI native? Thanks
[eluser]OverZealous[/eluser]
@Alface Why did you extend DataMapper directly?? There are half a dozen supported ways to write your own validation methods, and none of them require direct modification. The simplest method is to add your own _file_require method to your model, but you can also easily add it to an extension. Custom validation methods always override Form_validation methods. Please see the validation page in the manual for explicit examples.
[eluser]Alface[/eluser]
I tried but it only handle $_POST fields, I need to validate with $_FILES >.<
[eluser]OverZealous[/eluser]
@Alface :question: Custom validation functions can validate anything you want. They are just methods that return TRUE or FALSE. You can write anything you want for the method.
[eluser]Alface[/eluser]
I know but, the function validation don't handle custom error messagens by this functions.. take a look: Code: // Add an error message if the rule returned FALSE I changed to: Code: // Add an error message if the rule returned FALSE Am I wrong? How could I set a error message for an "Custom Validation Rule" ? |
Welcome Guest, Not a member yet? Register Sign In |