PHP Classes

File: WithGrid.php

Recommend this page to a friend!
  Classes of rudie dirkx   ROW Simple Form   WithGrid.php   Download  
File: WithGrid.php
Role: Class source
Content type: text/plain
Description: (Big) grid example
Class: ROW Simple Form
Validate and display HTML forms
Author: By
Last change:
Date: 13 years ago
Size: 1,252 bytes
 

Contents

Class file image Download
<?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(),
            ),
        );
    }

}