Welcome Guest, Not a member yet? Register   Sign In
Customizable CRUD
#12

[eluser]Atasa[/eluser]
Hey guys this is getting interesting...
My point of view is that we can discuss different ways and alternatives for ever.
Lets start from what we have already.
We have CI.
Then we check whether is OK this tool to work on.
Remember this is not an easy job.
I have looked for quite sometime now in frameworks, html generators, template systems etc.
The first thing that clicks to your mind when you see a framework is the philosophy it is based on.
If we have decided to use CI so lets see how far we can go, and if that is expensive too.
I also thing that some logic sould go also at the database it self.
One good example is the mysql database in MySql.

suashi you can try the following as well:

Code:
<?php

class Welcome extends Controller {
    
    
    function Welcome()
    {
        parent::Controller();
        $this->load->library('table');
        $this->load->helper('form');
        $this->load->helper('url');    
        
    }
    
    function index()
    {
    
    $form = array(
        'Row1' => array(
            'FIELD_NAME' => 'field1',
            'FORM_CAPTION' => 'Text for field1',
            'DEFAULT_VALUE' => 'enter text here',
            'EDIT_TYPE' => 'input',
            'LOOKUP_COMMAND' => ''
        ) ,
        'Row2' => array(
            'FIELD_NAME' => 'field2',
            'FORM_CAPTION' => 'Text for field2',
            'DEFAULT_VALUE' => 'Please make a Selection',
            'EDIT_TYPE' => 'select',
            'LOOKUP_COMMAND' => array ('key1'=>'value1','key2'=>'value2','key3'=>'value3')
        ) ,
        'Row3' => array(
            'FIELD_NAME' => 'field3',
            'FORM_CAPTION' => 'Please write your Details',
            'DEFAULT_VALUE' => '',
            'EDIT_TYPE' => 'textarea',
            'LOOKUP_COMMAND' => ''
        )
    );

    $oform = form_open('email/send')."\n";    
    $oform .= $this->table->set_heading('Name', 'Value');
    
    function BuildForm($myform)    
    {
        $mytable = &get;_instance();
        foreach ($myform as $array)
        {
            switch ($array['EDIT_TYPE'])
            {
                case 'input':
                $options = array('name' => $array['FIELD_NAME'], 'value' => $array['DEFAULT_VALUE'], 'maxlength' => '50');
                $mytable->table->add_row($array['FORM_CAPTION'], form_input($options));
                break;

                case 'textarea':
                $options = array('name' => $array['FIELD_NAME'],'value' => $array['DEFAULT_VALUE'],'rows' => '7','cols' => '50');
                $mytable->table->add_row($array['FORM_CAPTION'], form_textarea($options));
                break;

                case 'select':
                $mytable->table->add_row($array['FORM_CAPTION'], form_dropdown($array['FIELD_NAME'], $array['LOOKUP_COMMAND']));
                break;                                
            }
        }
    
    }
    BuildForm($form);
    
    $oform.= $this->table->generate();
    $oform.= form_reset('myreset', 'Reset Fields');
    $oform.= form_submit('mysubmit', 'Submit Post!');
    $oform.= "\n <br/>" . form_close() ;
    echo $oform;
    }//endIndex
    
    
}
?&gt;

It's small sample of binding an array to a form generator class.
for the sake of the example I have created a subfunction and used &get;_instance() method.
you can just run it by it self and see the results.

Very easy right?


Messages In This Thread
Customizable CRUD - by El Forum - 02-16-2008, 10:03 AM
Customizable CRUD - by El Forum - 02-19-2008, 02:18 PM
Customizable CRUD - by El Forum - 02-21-2008, 02:09 PM
Customizable CRUD - by El Forum - 02-22-2008, 03:12 AM
Customizable CRUD - by El Forum - 02-22-2008, 03:16 AM
Customizable CRUD - by El Forum - 02-22-2008, 04:09 AM
Customizable CRUD - by El Forum - 02-22-2008, 01:32 PM
Customizable CRUD - by El Forum - 02-22-2008, 01:44 PM
Customizable CRUD - by El Forum - 02-22-2008, 03:40 PM
Customizable CRUD - by El Forum - 02-22-2008, 04:45 PM
Customizable CRUD - by El Forum - 02-22-2008, 08:13 PM
Customizable CRUD - by El Forum - 02-23-2008, 05:36 AM
Customizable CRUD - by El Forum - 02-23-2008, 05:48 AM
Customizable CRUD - by El Forum - 02-23-2008, 06:42 AM
Customizable CRUD - by El Forum - 02-23-2008, 07:10 AM
Customizable CRUD - by El Forum - 02-23-2008, 08:06 AM
Customizable CRUD - by El Forum - 02-24-2008, 08:21 AM
Customizable CRUD - by El Forum - 02-24-2008, 08:49 AM
Customizable CRUD - by El Forum - 02-24-2008, 09:08 AM
Customizable CRUD - by El Forum - 02-24-2008, 12:17 PM
Customizable CRUD - by El Forum - 02-24-2008, 12:58 PM
Customizable CRUD - by El Forum - 02-25-2008, 04:32 AM
Customizable CRUD - by El Forum - 02-25-2008, 08:31 AM
Customizable CRUD - by El Forum - 02-25-2008, 01:50 PM
Customizable CRUD - by El Forum - 02-25-2008, 02:02 PM
Customizable CRUD - by El Forum - 02-26-2008, 12:17 PM
Customizable CRUD - by El Forum - 02-26-2008, 01:48 PM
Customizable CRUD - by El Forum - 02-28-2008, 05:27 PM
Customizable CRUD - by El Forum - 02-29-2008, 04:03 AM
Customizable CRUD - by El Forum - 02-29-2008, 04:17 AM
Customizable CRUD - by El Forum - 02-29-2008, 05:00 AM
Customizable CRUD - by El Forum - 03-01-2008, 04:27 AM
Customizable CRUD - by El Forum - 03-01-2008, 04:45 AM
Customizable CRUD - by El Forum - 03-01-2008, 04:49 AM
Customizable CRUD - by El Forum - 03-01-2008, 05:47 AM
Customizable CRUD - by El Forum - 03-01-2008, 06:14 AM
Customizable CRUD - by El Forum - 03-01-2008, 02:38 PM
Customizable CRUD - by El Forum - 03-22-2008, 03:06 PM
Customizable CRUD - by El Forum - 03-24-2008, 08:11 AM
Customizable CRUD - by El Forum - 03-24-2008, 12:15 PM
Customizable CRUD - by El Forum - 03-26-2008, 07:24 AM
Customizable CRUD - by El Forum - 03-30-2008, 04:10 PM
Customizable CRUD - by El Forum - 06-09-2008, 10:54 PM
Customizable CRUD - by El Forum - 06-10-2008, 01:19 AM
Customizable CRUD - by El Forum - 06-10-2008, 09:42 AM
Customizable CRUD - by El Forum - 06-10-2008, 09:45 AM
Customizable CRUD - by El Forum - 06-11-2008, 01:35 PM
Customizable CRUD - by El Forum - 02-20-2009, 11:32 AM
Customizable CRUD - by El Forum - 02-22-2009, 12:06 PM
Customizable CRUD - by El Forum - 02-26-2009, 07:03 AM
Customizable CRUD - by El Forum - 04-29-2009, 05:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB