ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

[Deprecated] DMZ 1.6.2 (DataMapper OverZealous Edition)

November 23, 2009 11:54pm

Subscribe [46]
  • #301 / Feb 18, 2010 3:45am

    Oblique

    32 posts

    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):

    // 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.

  • #302 / Feb 18, 2010 7:18am

    wandschrank

    6 posts

    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:

    $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.

  • #303 / Feb 18, 2010 7:31am

    Conerck

    15 posts

    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.

    You can use the include_related() method for this like so.

    $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/getadvanced.html#include_related

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

  • #304 / Feb 18, 2010 8:44am

    wandschrank

    6 posts

    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

  • #305 / Feb 18, 2010 10:12am

    NachoF

    171 posts

    Ok, Phil.. I can understand it.. it did seem like a fairly complicated extension.

    I guess its back to writing my own forms again.

  • #306 / Feb 18, 2010 7:51pm

    macigniter

    244 posts

    I am trying to query a dataset with the following function with DMZ:

    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 :(

  • #307 / Feb 18, 2010 7:56pm

    NachoF

    171 posts

    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

    $g=new Group();
                $g->get();
                $data['groups']=$g;
                $this->template->load('master','users/create',$data);

    and in my view

    <?= form_dropdown('groups', $groups);?>

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

  • #308 / Feb 18, 2010 8:08pm

    OverZealous

    1030 posts

    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 :(

    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:

    $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.)

  • #309 / Feb 19, 2010 2:27am

    NachoF

    171 posts

    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

  • #310 / Feb 19, 2010 2:31am

    OverZealous

    1030 posts

    @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.

  • #311 / Feb 19, 2010 2:33am

    NachoF

    171 posts

    No, I dont want a single generic message…I just need to change the error strings cause I need them in spanish.

  • #312 / Feb 19, 2010 2:35am

    OverZealous

    1030 posts

    Oh, then you simply need to load Spanish language files for CodeIgniter.  The error messages for those rules are part of CodeIgniter (see system/language/english/form_validation_lang.php).

    Edit: I should mention that I have no idea how or where to get them.  But I assume you can safely install them into application/language.

  • #313 / Feb 19, 2010 2:37am

    BaRzO

    105 posts

    You can find lang files at All CI Lang Files

  • #314 / Feb 19, 2010 2:41am

    NachoF

    171 posts

    Thanks…
    You think if I put spanish lang file for 1.7.0 it will work in 1.7.2?

  • #315 / Feb 19, 2010 3:03am

    OverZealous

    1030 posts

    @NachoF
    I can’t speak for certain, but my last few updates of CodeIgniter have not included any language file changes.

    If you are really concerned, just make sure every key from the English files is present in the Spanish files.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases