Welcome Guest, Not a member yet? Register   Sign In
[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)

[eluser]Oblique[/eluser]
If someone has a problem with htmlform ext where <option>'s are generated from related object list but value's are not id's but just sequential iterator values like 0,1,2,3 - solution is to change one line in _options function (near line 617 or smth like that):
Code:
// doesn't work $a = array('value' => $opt);
$a = array('value' => $label->id);

Disclaimer: i think there might be some unexpected collisions with this since _options is user elsewhere, but it works for me for now.

[eluser]wandschrank[/eluser]
Hi Phil,
first, i am new to your DMZ ORM-System. I find it extremly useful, thank you for it. But with this thing i have a blackout:
Code:
$s = new Serial();
        $s->select('id,title')->get();

        foreach( $s as $serie)
        {
            $serie->author->select('id,name,firstname')->get();
        }

        $this->load->view('serials/list', array('serials' => $s));
I mean this foreach-thing. Isn't there a clever way to get the authors for any serial? With this i have one SQL-statement for each serial. It works, but not very smart.
Sorry for my bad english.

[eluser]Conerck[/eluser]
[quote author="wandschrank" date="1266513487"]
I mean this foreach-thing. Isn't there a clever way to get the authors for any serial? With this i have one SQL-statement for each serial. It works, but not very smart.
Sorry for my bad english.[/quote]

You can use the include_related() method for this like so.
Code:
$s = new Serial();
$s->select('id,title')
  ->include_related('author', array('id', 'name', 'firstname')->get();

$this->load->view('serials/list', array('serials' => $s));

This should work, I believe. Take a look at the appropriate section in the User Guide if it doesn't. http://www.overzealous.com/dmz/pages/get...de_related

EDIT: This is assuming that Serial -> Author is a has_one relationship

[eluser]wandschrank[/eluser]
Thank you for the quick answer Conerck. I've found it already in the manual. But it IS a "has_many" Serial->Author relation and i found no adequate approach.
greetings

[eluser]NachoF[/eluser]
Ok, Phil.. I can understand it.. it did seem like a fairly complicated extension.

I guess its back to writing my own forms again.

[eluser]macigniter[/eluser]
I am trying to query a dataset with the following function with DMZ:

Code:
SELECT * FROM table WHERE 'created' = DATE_SUB('2010-01-01', INTERVAL 1 MONTH);

How can I accomplish this with DMZ?? I have tried with the ->where_func() method, but failed Sad

[eluser]NachoF[/eluser]
ok, so say I want to create a "form_dropdown" with a bunch of groups... whats the fastest way to get this done?? Im not using htmlform plugin but what about the array conversion methods?.
in my controller
Code:
$g=new Group();
            $g->get();
            $data['groups']=$g;
            $this->template->load('master','users/create',$data);
and in my view
Code:
&lt;?= form_dropdown('groups', $groups);?&gt;

This obviously doesnt work but how exactly could I fix it?

[eluser]OverZealous[/eluser]
[quote author="macigniter" date="1266558697"]
Code:
SELECT * FROM table WHERE 'created' = DATE_SUB('2010-01-01', INTERVAL 1 MONTH);

How can I accomplish this with DMZ?? I have tried with the ->where_func() method, but failed Sad[/quote]

Because of the "INTERVAL 1 MONTH" not being a string, I can't make it work with the DMZ methods. However, there's no need to use the DMZ methods anyway, since it is all simple arguments. I'd just do this:

Code:
$o = new Object();
// you can use $o->db->escape() if the date is dynamic
$o->where('created', "DATE_SUB('2010-01-01', INTERVAL 1 MONTH)", FALSE);
$o->get();

(The real purpose of the *func methods is that it can automatically handle related fields.)

[eluser]NachoF[/eluser]
Im trying to figure out how to change the error message for specific rules on the same field... for instance, say my email field has two validation rules. its required and it must be a valid email... how can I change the error message string for both of these rules?

btw, the reason I need this is cause my validation errors must be in spanish

[eluser]OverZealous[/eluser]
@NachoF
I'm not sure what you are asking. The error message is based on the rule. There is a different message for each rule. They cannot (practically) be overridden.

If you want to display a single, generic error message, then you should detect that an error has occurred and render whatever error you want.

Alternatively, write custom _required and _valid_email validation rules for that model, and return the error message you want if an error occurs.




Theme © iAndrew 2016 - Forum software by © MyBB