<?php 
namespace app\forms; 
use app\models; 
use app\specs\Output; 
class WithGrid extends \app\specs\SimpleForm { 
    protected function renderGridHorizontalTH( $element, $label ) { 
        $title = $label->description ? ' title="'.$label->description.'"' : ''; 
        $html = '<th class="horizontal"'.$title.'>'.$label.'</th>'; 
        return $html; 
    } 
    protected function elements( $defaults = null, $options = array() ) { 
        return array( 
            'password' => array( 
                'type' => 'password', 
                'description' => Output::translate('Admin password to prove you\'re one of the hims/hers.') 
            ), 
            'prefs' => array( 
                'type' => 'grid', 
                'subtype' => 'options', 
                'options' => models\Category::all(), 
                'reverse' => true, // reverses X and Y in **element names** (vertical is still vertical and horizontal is still horizontal) 
                'title' => Output::translate('Choose categories'), 
                'horizontal' => array( 
                    Output::translate('Domain'), 
                    models\Domain::all(), 
                ), 
                'vertical' => array( 
                    Output::translate('User'), 
                    models\User::all(), 
                ), 
                'description' => Output::translate('One category per user / domain combination'), 
            ), 
            'cat' => array( 
                'type' => 'options', 
                'options' => models\Category::all(), 
            ), 
        ); 
    } 
 
} 
 
 |