示例#1
0
 public function add($type, $name, $value, $info)
 {
     $info['value'] = empty($info['value']) ? $value : $info['value'];
     $info['label'] = empty($info['label']) ? preg_replace('/\\[[a-zA-Z0-9_ ]*\\]/', '', $name) : $info['label'];
     $element_name = $this->name_is_array ? $this->name . '[]' : $this->name;
     if ($this->name_is_array and preg_match('/\\[([a-zA-Z0-9_ ]+)\\]/', $name, $matches)) {
         $element_name = $this->name . '[' . $matches[1] . ']';
     }
     Formo::include_file('driver', $type);
     $class = 'Formo_' . $type . '_Driver';
     $this->{strtolower(str_replace(' ', '_', $name))} = new $class($element_name, $info);
 }
示例#2
0
<?php

defined('SYSPATH') or die('No direct script access.');
/*=======================================

Formo Plugin HABTM

Must be loaded instead of orm plugin (this extends it)

=======================================*/
Formo::include_file('plugin', 'orm');
class Formo_habtm extends Formo_orm
{
    protected $elements = array();
    protected $habtm_model = array();
    protected $habtm_plural = array();
    protected $habtm_table = array();
    protected $habtm_name = array();
    public function __construct(&$form)
    {
        parent::__construct($form);
        $this->form->add_function('habtm', array($this, 'habtm'));
    }
    public static function load(&$form)
    {
        return new Formo_habtm($form);
    }
    public function habtm($model = NULL, $table = NULL, $id = NULL)
    {
        if (!$id and !$table) {
            $table = $model;
 public function type($new_type)
 {
     Formo::include_file('driver', $new_type);
     $form = Formo::instance($this->formo_name);
     $vals = get_object_vars($this);
     unset($form->{$this->name});
     unset($vals['type']);
     unset($vals['tags']);
     $form->add($new_type, $this->name, $vals);
     return $this;
 }