CodeIgniter Forums
CodeExtinguisher 2.0 Public Beta (RC10) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: CodeExtinguisher 2.0 Public Beta (RC10) (/showthread.php?tid=6065)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]Clooner[/eluser]
Looks very promising...

Somehow the download is corrupt...

Can you also use relations? E.G. show all the available rows from Table_A and make their id's set to a field in Table_X?

Keep up the good work.


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]MaRKTD[/eluser]
Table
Code:
CREATE TABLE `category` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(128) character set utf8 NOT NULL,
  `img` varchar(100) character set utf8 default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

category_form.yml
Code:
title:
    class: TextBox
img:
    class: Image
    params:
        make_thumbnail: true
        height:180
        width:129
        url_path: img/
        upload_path: D:/denwer/home/site/www/img/

category.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
*
* NOTE:
*   This controller does not generate tables, you must predefine you table.
*
*/
include("codexcontroller.php");

class Category extends codexController
{
    function Category ()
    {
        // Load the CodexController
        codexController::codexController();

        // We include the spyc library
        // So that we can define our form
        // in a YAML file as opposed to
        // hand-writing the array in $config
        $this->load->library('spyc');                

        // To make the field names more human
        // friendly
        $this->load->helper('inflector');


        /*
         * ===================================
         * ADDING VALIDATION
         * ===================================
         *
         * If you would like to add form
         * validation, then define your
         * rules in the following format:
         *
         *      $rules['field_name'] = "rules";
         *
         * then in your $config array below:
         *
         *      'rules' => $rules,
         *
         * ===================================
         */

        $config = array(
                    'db_table' => 'category', //The name of the table associated with this controller
                    'form_setup' => $this->spyc->YAMLLOAD('definitions/category_form.yml'), //The array that holds our elements
                    'controller_name' => 'Category', //The name of the controller, so that it can be used when generating the URLs
                    'list_text' => array('title'), //The fields to be displayed in the "overview" view
                    );
        $this->setConfig($config);
        $this->load->scaffolding('category');
    }
}
?>


error string
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Image::$CI

Filename: plugins/image.php

Line Number: 36
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: plugins/image.php

Line Number: 36

Fatal error: Call to a member function library() on a non-object in Z:\home\site\www\codex\application\plugins\image.php on line 36

The example works. In what a mistake?


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]mandarin[/eluser]
MarKTD: The example works because a file upload field is loaded before the image upload field. Try adding "test: class: file" to your category_form.yml file. I found that bug yesterday and will look for a solution today.

Kind Regards,
Mark


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]Majd Taby[/eluser]
mandarin, MaRKTD, sorry for the delayed response, I can't recreate the errors, i've used MaRKTD's code as well, but it seems to be working on my machine.

Could you guys go to application/plugins/image.php and delete line 22 and tell me if that fixes the problem?

Thanks,
jTaby


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]mandarin[/eluser]
Of course! I will try that one out when I am back home Smile

Maybe in the meantime I can try and specify the bug a bit:
I am using PHP5 and CI 1.6 on a local dev box. The problem seems to be that the CI class is not instantiated when I just define a Image upload in a yml file. When I add a standard file upload field before the image field in yml file, the Image field works fine.

Kind Regards


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]Majd Taby[/eluser]
well, lines 22 and 23 are:

Code:
if(!class_exists('File'))
    include('file.php');

The reason being that when a form is being generated, it includes all the plugin files it needs, so if you include something twice, then it thinks you're defining two classes of the same name...


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]mandarin[/eluser]
I am not sure if we are talking about the same right now. Maybe it is me who is not fully focused as I am currently at work and cannot take a look at the code. However, I it works when I define _both_ fields not just one. So it is kinda like the opposite of what you are suggesting as it does not work if I just define one field (when there is just one class loaded then).

Kind Regards,
Mark


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]MaRKTD[/eluser]
[quote author="jTaby" date="1203365564"]mandarin, MaRKTD, sorry for the delayed response, I can't recreate the errors, i've used MaRKTD's code as well, but it seems to be working on my machine.

Could you guys go to application/plugins/image.php and delete line 22 and tell me if that fixes the problem?

Thanks,
jTaby[/quote]
Does not work. A mistake in that that variables from file are used and in a class image they are inaccessible. CI 1.6.1 from SVN. The version another can at you? Try to put on clear CI


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]Majd Taby[/eluser]
Here, try the code in the link. This is the Image plugin, but made independent of the File plugin.
http://rafb.net/p/DPs0f997.html


CodeExtinguisher 2.0 Public Beta (RC10) - El Forum - 02-18-2008

[eluser]MaRKTD[/eluser]
[quote author="jTaby" date="1203367356"]Here, try the code in the link. This is the Image plugin, but made independent of the File plugin.
http://rafb.net/p/DPs0f997.html[/quote]
Yes it works)