[Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) |
[eluser]OverZealous[/eluser]
@BrianDHall I'm glad you are excited about get-rules, but you can make it oh-so-much simpler. The rules will happily call native PHP functions, so you can just do this: Code: var $validation = array( And, in fact, this the explicit example in the docs ;-) Unless it isn't working for you for some reason!
[eluser]OverZealous[/eluser]
[quote author="introvert" date="1256588941"] I'm trying to join 2 tables with DM OZ edition, where field 'domain' is the same. Entry model: id last_updated domain Filter model: id domain priority[/quote] Hi, introvert, DMZ will only work with the integer-based id fields for relationships. You didn't mention if this was a One-to-One, One-to-Many, or Many-to-Many relationship, but if it is a One-to-XXX relationship, then I recommend only storing the domain on one side of the relationship. You'll need to add a standard relationship column to the other object. Then you can query and access the domain using normal relationship methods. For example, let's assume that each Entry has One Filter, and each Filter has Many Entries. First, add a column filter_id to Entry. Remove the domain column from Entry, as well. Then you can access and query Entry like so: Code: $e = new Entry();
[eluser]OverZealous[/eluser]
[quote author="BrianDHall" date="1256595922"] I would like to do some custom processing on save, with some magic features kind of like how created and updated fields work in DMZ. How might I extend DMZ to allow me such an ability, if possible?[/quote] Form Validation is fine for this. What you would want to do is make a custom rule for IP like this: Code: function _insert_ip_on_new($field) { Then add that rule to your IP column, first if you can. You can still process other rules after, if necessary (like unique).
[eluser]BrianDHall[/eluser]
[quote author="OverZealous" date="1256605603"]@BrianDHall I'm glad you are excited about get-rules, but you can make it oh-so-much simpler. The rules will happily call native PHP functions, so you can just do this: Code: var $validation = array( And, in fact, this the explicit example in the docs ;-) Unless it isn't working for you for some reason![/quote] Well I'll be damned! LOL Actually I never even thought to try using it directly, didn't even make the connection that the example would work for DMZ's magic fields. Hey, the less code to write the better. I'm as proud as hell that I'm just finishing off a voting system with two different forms and three models, and it's all less than about 100 lines of original code. I spent about 8 hours on it and forgot to email myself my work from home so I did it all over again, and this time it only took me three hours ![]() -Brian
[eluser]umefarooq[/eluser]
@BrianDHall it tried the code you suggest but it giving me the following error Code: $content = new Content(); and here is my models Code: content Code: menu model
[eluser]BrianDHall[/eluser]
@ umefarooq Hm, never seen that error before. What line throws the error? If it is the last line, sepparate it so you can see if it is the relationship saving that's the issue or the save command itself, such as: Code: $content->save(); If is the relationship make sure you have a join table defined properly, but I think if that were the issue you'd be getting a "could not relate objects" message.
[eluser]OverZealous[/eluser]
That error is called when trying to 'update' a database table with no changed values. As BrianDHall said, you probably need to save the content model first. Edit: for clarification.
[eluser]BrianDHall[/eluser]
[quote author="OverZealous" date="1256606629"][quote author="BrianDHall" date="1256595922"] I would like to do some custom processing on save, with some magic features kind of like how created and updated fields work in DMZ. How might I extend DMZ to allow me such an ability, if possible?[/quote] Form Validation is fine for this. What you would want to do is make a custom rule for IP like this: Code: function _insert_ip_on_new($field) { Then add that rule to your IP column, first if you can. You can still process other rules after, if necessary (like unique).[/quote] I had overlooked your response here, and I finally got it all working. Just a hint for those unsure, but be sure to define 'required' AFTER you set your custom field on something like this, otherwise the rule won't run. And don't forget the _ in front of the function, or it might not run either ![]() Thanks OverZealous, got back working on this again. Now to the next problem... |
Welcome Guest, Not a member yet? Register Sign In |