Skip to content

Generation of forms accordind to database tables and columns

License

Notifications You must be signed in to change notification settings

Zheness/phalconFormGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phalconFormGenerator

VERSION 2.0

phalconFormGenerator is a simple script used to generate forms according to the columns of a table.

Note: this version 2.0 no longer require a web server to run. Simply install the packages and launch the script!

Installation and usage

  1. Download this repo
  2. Run composer install command to install packages
  3. Configure database access in app/config/config.php
  4. Start the generation with ./run

You can run ./run help to read the help for the command.

The files will be generated in the output folder.

Example:

You have a table users with inside a column firstname (of type VARCHAR and size 75);

After running the script, this code will be generated:

class UsersForm extends \Phalcon\Forms\Form
{
    public function setFields()
    {
        $this->add($this->firstnameField());
    }
    
    private function firstnameField()
    {
        $element = new \Phalcon\Forms\Element\Text("firstname");
        $element->setLabel("firstname");
        $element->addValidator(new \Phalcon\Validation\Validator\StringLength([
            "max" => 75
        ]));
        return $element;
    }
}

For another example, the folder example contains the structure of a database and the files generated.

What's next ?

Some type of fields are not generated, selects are empty, relationships are not implemented, etc.

If you want to contribute, feel free to!

About

This project was tested with this configuration:

  • PHP : 7.0.12
  • MySQL : 5.7.16
  • Phalcon : 3.0.3

About

Generation of forms accordind to database tables and columns

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages