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

[eluser]silvergear99[/eluser]
OverZealous

Made som debugging and it seems like 'radio' allways returns an array. That's way I got the error.

So now I have to do like this. But it works
Code:
$tmp = $this->input->post('enabled');
$user->enabled = $tmp[0];
$user->save()

Would be much easier if it didn't return an array but I'm sure you have a valid reason for this Smile

Also I have to change to this (in the user model):
Code:
'values' => array(1=>'No',2 =>'Yes')
because
Code:
'values' => array(0=>'No',1 =>'Yes')
allways return the following array no matter what option you choose:
Code:
Array
(
    [0] => 1
)

[eluser]coldKingdom[/eluser]
Hello!

Couldn't delete my question so I will just say thank you instead Smile

[eluser]Oblique[/eluser]
+1 to the recently discussed "radio" problem. same s**t.
don't realy see the reason to render radios as "name=$blah[]"
and "from_array()" does not work as well in that case
Looks like some kind of "oops, forgot this" while writing htmlform, while it is really cool ext!

btw DMZ is half of a CI for me or even more

upd: a little workaround while Phil allmighty thinks how to make this gracefuly:

htmlform.php
697
Code:
if(is_array($value) AND $type != 'radio')

[eluser]Brandon Jackson[/eluser]
I thought I would share the solution to a problem that had been plaguing me of late. DataMapper was throwing errors for every request which read:

Quote:Message: Invalid argument supplied for foreach()
Filename: libraries/datamapper.php
Line Number: 422

Message: array_keys() [function.array-keys]: The first argument should be an array
Filename: libraries/datamapper.php
Line Number: 88

In addition to annoying me, these errors prevented extensions from loading. As it turns out, I had set the datamapper config file to autoload. This was causing the problem. I cleared the autoload config array and everything worked fine. Hope this solves someone elses problem.

[eluser]rideearthtom[/eluser]
Just a quick one to say thanks for the most useful CI library I could imagine. It's cut my dev time and the number of lines of code written by about 90%. You rule! Smile

[eluser]Jakebert[/eluser]
Super question, probably stupid:

is it possible to have one model cater to two different controllers? Let's say I've got my student model, and then my students controller (which handles CRUD/admin) and my student controller, so that users can view individual profiles without having access to the admin/CRUD stuff. Is that possible? Right now I'm getting a cannot redeclare class error in the model.

[eluser]OverZealous[/eluser]
@Jakebert

This is your answer.

:-)

[eluser]Alface[/eluser]
to use DMZ with HMVC I hacked datamapper libraries (system\application\libraries)
I couldn't extend without losing the functionality to make a custom datamapper's extended class for each module
actily, I think it is not even possible to extend autoload datamapper native class.

Code:
static function autoload($class)
    {
        // Don't attempt to autoload CI_ or MY_ prefixed classes
        if (in_array(substr($class, 0, 3), array('CI_', 'MY_')))
        {
            return;
        }

        // Prepare class
        $class = strtolower($class);

        // Seach on application folder
        // Prepare path
        $path = APPPATH . 'models';

        // Prepare file
        $file = $path . '/' . $class . EXT;
        
        
        // Check if file exists, require_once if it does
        if (file_exists($file))
        {
            require_once($file);
        }
        else
        {
            // Do a recursive search of the path for the class
            DataMapper::recursive_require_once($class, $path);
        }
        
        
        
        // Seach on Modules folders
        
        // Prepare path
        $path = APPPATH . 'modules';
        
        if(is_dir($path) ){
            if ($handle = opendir($path)){
                while (FALSE !== ($dir = readdir($handle))){
                    // If dir does not contain a dot
                    if (strpos($dir, '.') === FALSE){
                        $modules[] = $dir;
                    }
                }
            }
        }
        
        foreach($modules as $module){
            // Prepare path
            $path = APPPATH . 'modules/'.$module.'/models';
            
            // Verify if there is a models folder on Module folder
            if(is_dir($path) ){
                // Prepare file
                $file = $path . '/' . $class . EXT;
    
                // Check if file exists, require_once if it does
                if (file_exists($file))
                {
                    require_once($file);
                }
                else
                {
                    // Do a recursive search of the path for the class
                    DataMapper::recursive_require_once($class, $path);
                }
            }
        }
    }

I needed to edit system\application\datamapper\htmlform.php too
turn it
Code:
// this is the default template (view) to use for the overall form
    var $form_template = 'dmz_htmlform/form';
    // this is the default template (view) to use for the individual rows
    var $row_template = 'dmz_htmlform/row';
    // this is the default template (view) to use for the individual rows
    var $section_template = 'dmz_htmlform/section';
intro this
Code:
// this is the default template (view) to use for the overall form
    var $form_template = '../dmz_htmlform/form';
    // this is the default template (view) to use for the individual rows
    var $row_template = '../dmz_htmlform/row';
    // this is the default template (view) to use for the individual rows
    var $section_template = '../dmz_htmlform/section';

I think it will work with any Modular Extension (ME) like Matchbox.
I didn't find any post about it on the forum, if anyone know a better way to do it, let me know

[eluser]Oblique[/eluser]
Incorrect value in htmlform-generated dropdown

Instead of id's from DM's i supplied, dropdown value attrubutes are set to 0-1-2-3 and so on;

I set up rendering like this:
Code:
$driver_fields = array
    (
        'Driver' => 'section'
        ,'name' => array('value' => '')
        ,'phone' => array('value' => '')
        ,'passport' => array('value' => '')
        ,'existing_driver' => array
            (
                'label' => 'Already existing'
                ,'type' => 'dropdown'
                ,'list' => $client->driver
            )
    );

and then:
Code:
<?= $client->driver->render_form($driver_fields ,'' ,array(), 'dmz_htmlform/form_fragment') ?>

Renderer gives me this:
Code:
<select name="existing_truck" id="existing_truck">
<option value="0" selected="selected">Driver_6</option>
<option value="1">Driver_15</option>
...

[eluser]chadbob[/eluser]
I need some HTML form extension help...I've got it working and saving forms, but it's missing one of my relationships.


Here is my DB table structure:

locations
locations_statutes
reports (reports has an in table foreign key for location)
reports_statutes
statutes

Everything works as normal when reading from the DB.

When the HTML form extension saves a report, a new report table entry is made, and reports_statutes is updated with the relationship, but it doesn't update the locations_statutes table with that relationship.

Here are the field snippets from my code:
Code:
// This is how are form will be rendered
       $form_fields = array(
             'id',
            // Section header
            'Report Contents' => 'section',
            'date',
            'description',

            // Section header
            'Locations and Statutes' => 'section',
            'location',
            'statute'

Code:
// Use the (already-loaded) array extension to process the POSTed values.
           $rel = $rep->from_array($_POST, array(
                   'id',
                // Section header
                'section',
                'date',
                'description',
                'location',
                'statute'




Theme © iAndrew 2016 - Forum software by © MyBB