nciri / zend-db-model-generator

Automatically exported from code.google.com/p/zend-db-model-generator
0 stars 0 forks source link

Form generation #15

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I haven't followed the the project lately, but it would be great to include ZF 
form generation as well which can save precious programming time.

Please find attachement of my form template. I'm using this in my projects and 
works great.

In order it to work you will need to define form_type value (a conversion from 
php_value) in the generator class. This should look like something like this:

    private function _convertTypeToForm($str) {
        if (in_array($str, array('text'))) {
            $res = 'textarea';
        } elseif (in_array($str, array('boolean', 'bool'))) {
            $res = 'checkbox';
        } else {
            $res = 'text';
        }

        return $res;
    }

 $columns[] = array(
                        'field' => $field,
                        'type' => $type,
                        'phptype' => $this->_convertPgsqlTypeToPhp($type),
                        'formtype' => (substr($field, -3) == '_id' ? 'select' : $this->_convertTypeToForm($type)),
                        'is_required' => $notNull,
                        'is_primary' => $isPrimary,
                        'capital' => $this->_getCapital($field)
                    );

Original issue reported on code.google.com by istvan.c...@gmail.com on 27 Oct 2011 at 7:15

Attachments:

GoogleCodeExporter commented 8 years ago
That would be a nice thing to have, but I don't think it really should be added 
to ZDMG. 
Forms are a part of the code in which you really need a lot of control. 
What we could do is to generate an abstract form class, so you can extend and 
manipulate it from an child form.

On the other hand, there are so many issues and features to be made on ZDMG 
that this can't be taken as a priority.

Original comment by pedrospdc on 18 Feb 2012 at 6:11