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

[eluser]OverZealous[/eluser]
Well, that was easy. Assuming I didn't make any mistakes, I simply changed the replacement regex for subquery to only replace the tablename if it wasn't prefixed with _.

Simply enough, and covers the common cases.

Anyway, thanks (very much) to Cro_Crx for providing such a clear test case and making it so easy to track down!

An updated release with this bugfix, the new language files, and other recent bugfixes is being prepped right now. It should be out in 20 minutes or so.

[eluser]OverZealous[/eluser]
Ok, the update is out. Version 1.6.2 contains bug fixes, the new language files, and a variety of minor updates to the manual.

Quote:Download the Latest Version Here

View the change log and the upgrade process
Having issues? Please look through the Troubleshooting Guide & FAQs
View the Complete Manual
Search the Manual
(Due to the server's caching configuration, you may need to forcibly refresh your browser to see the changes in the manual.)

[eluser]12vunion[/eluser]
I think I've found another bug. There is a problem with default values in validation/get rules. An empty string is being passed instead of a NULL when no param is set. This is stopping default values from being used.

Code:
var $validation = array(
    'field1'    => array(
        'get_rules' => array('max_tacos' => 75),
    ),
    'field2'    => array(
        'get_rules' => array('max_tacos'),
    ),
...

function _max_tacos($field, $param=5){
    //field1 $param type is int, value is 75
    //field2 $param type is string, value is ''
}

[eluser]OverZealous[/eluser]
@12vunion

That's not a bug - that's how it is designed. It mirrors the way validation rules work exactly.

The end result is you cannot have default values on get_rules parameters, or you must explicitly check for the empty string and set the value.

[eluser]Michael Ditto[/eluser]
Require At Least

My small contribution to the DMZ community, hope it's helpful for you.

Example:

Say you have a community website, and besides the regular contact information for a user, you want to have at least something on the user's profile page so that it's not a big sea of blankness. So you might create a model that looks like this:

Code:
class User extends DataMapper {
    
    var $extensions = array('require_at_least');

    var $validation = array(
        /* Other User validation fields omitted for brevity's sake */
        'about' => array(
            'label' => 'About You',
            'rules' => array('max_length' => 200,'trim')
        ),
        'favorite_quote' => array(
            'label' => 'Favorite Quote',
            'rules' => array('max_length' => 200,'trim')
        ),
        'fondest_memory' => array(
            'label' => 'Your Fondest Memory',
            'rules' => array('max_length' => 200,'trim')
        ),
        'form_completeness' => array(
            'label' => 'Form Completeness',
            'rules' => array(
                'always_validate' // Important step, otherwise the rule won't run
                'require_at_least' => array(
                    'num_required' => 1,
                    'fields' => array(
                        'about',
                        'favorite_quote',
                        'fondest_memory'
                    )
                )
            )
        )
    );
}

Each of the validation elements 'about', 'favorite_quote', and 'fondest_memory' corresponds to a field in the database. But that last element is a non-field validation rule (think "Confirm Password" from the DMZ examples).

Require At Least provides a rule that allows you to require that 'num_required' of the 'fields' you specify are filled in. If the minimum number is not met, an error will be set. In the case of the example above, the error would read, "You must supply at least one of the fields About You, Favorite Quote, or Fondest Memory."

Download it here.

I'll do my best to answer questions about it here if I can, but can't guarantee it as I'm about three deadlines behind already. :-)

[eluser]OverZealous[/eluser]
@michael Ditto

Very slick. That's a great example of a validation extension.

Don't forget you can (and should) require the extension this way:
Code:
class User extends DataMapper {
    // User needs the require_at_least validation extension
    var $extensions = array('require_at_least');
    ...

This should work without issue, and keeps you from having to override the constructor unnecessarily.

[eluser]Michael Ditto[/eluser]
[quote author="OverZealous" date="1262075185"]@michael Ditto

Very slick. That's a great example of a validation extension.

Don't forget you can (and should) require the extension this way:
Code:
class User extends DataMapper {
    // User needs the require_at_least validation extension
    var $extensions = array('require_at_least');
    ...

This should work without issue, and keeps you from having to override the constructor unnecessarily.[/quote]

Ahh! Done. I completely missed that convention.

[eluser]Cro_Crx[/eluser]
[quote author="OverZealous" date="1262049238"]Anyway, thanks (very much) to Cro_Crx for providing such a clear test case and making it so easy to track down![/quote]

Thanks for fixing it so quickly. I went to bed just after posting that, when I woke up this morning it was already fixed Smile

[eluser]Cro_Crx[/eluser]
I've just downloaded the latest copy. Seems to be working well. Although up the top it's showing the wrong version in the comments:

Code:
* @version     1.6.1 ($Rev: 292 $) (Based on DataMapper 1.6.0)

[eluser]OverZealous[/eluser]
Doh! Thanks for catching that.

Stupid complex update routine...

Edit: OK, the download has the updated version number!




Theme © iAndrew 2016 - Forum software by © MyBB