2017 © Pedro Peláez
 

library php-magic

phpMagic: Propel ORM & Bootstrap integrated to make building Pages, Forms & Lists easy

image

ajurgensen/php-magic

phpMagic: Propel ORM & Bootstrap integrated to make building Pages, Forms & Lists easy

  • Tuesday, February 14, 2017
  • by ajurgensen
  • Repository
  • 2 Watchers
  • 1 Stars
  • 227 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

phpMagic, (*1)

Takes Propel ORM Object and creates a bootstrap form - Also build lists and whole pages - does XSS security - Adds related tables automagiclly - Option to add other tables as needed (many-to-many) - Renaming of colum names - Excluding colums - Client Side Validation - Server Side Validation - Validation Callbacks - Use to create lists of objects - Use to create whole pages (with auth etc), (*2)

Installation: composer require ajurgensen/phpMagic, (*3)

Some ways of using phpMagic, (*4)

//Edit for User 
use \ajurgensen\phpMagic\formMagic;
if (!$userid || !$user = UserQuery::create()->findOneById($userid))
{
  $user = new User();
}
$names['UGLY_COLUM_NAME'] = 'This is a nicer name';
$options['FM_EXCLUDE'] = array ('PASSWORDHASH','UPDATED_AT','CREATED_AT');
$fm = new formMagic($user,$options,$names);
if ($fm->entitySaved)
{
    //all good, user updated - now redirect to some other page (entity is saved, etc) 
}else
{
    //Show the form
    echo $fm->html;
}

Another Way, (*5)

//Build a page with a list of objects
use \ajurgensen\phpMagic\formMagic;
use \ajurgensen\phpMagic\pageMagic;
$menu = array(
'Menu Point One' =>array('subpoint one' => '/one/one','subpoint two' => '/one/two'),
'Menu Point Two' =>array('subpoint one' => '/two/one','subpoint two' => '/two/two'));
$pm = new pageMagic('List Entities');
$pm->addMenu($menu);
$entites = EntityQuery::create()->find();
foreach($entites as &$entity)
{
    $entity->link = "/edit/entity/" . $entity->getId();
}
$options['LM_LINK'] = array('name');
$options['LM_ADDNEW'] = "/edit/entity/0";
$lm = new listMagic($entities,$options);
if ($lm->HTMLready)
{
    $pm->addHtml($lm->getHTML());
}
$pm->finalize();
}

The Versions

14/02 2017

dev-master

9999999-dev

phpMagic: Propel ORM & Bootstrap integrated to make building Pages, Forms & Lists easy

  Sources   Download

MIT

The Requires

 

by Andreas Jurgensen