schema = $schema;
}
/**
* Returns the Admin Form to edit the schema
*
* This data is processed by the SchemaBuilder class
*
* @return string the HTML for the editor form
* @see SchemaBuilder
*/
public function getEditor() {
$form = new Form(array('method' => 'POST'));
$form->setHiddenField('do', 'admin');
$form->setHiddenField('page', 'struct');
$form->setHiddenField('table', $this->schema->getTable());
$form->setHiddenField('schema[id]', $this->schema->getId());
$form->addHTML('
');
$form->addHTML('
Sort
Label
Multi-Input?
Configuration
Type
'); // FIXME localize
foreach($this->schema->getColumns() as $key => $obj) {
$form->addHTML($this->adminColumn($key, $obj));
}
// FIXME new one needs to be added dynamically, this is just for testing
$form->addHTML($this->adminColumn('new1', new Column($this->schema->getMaxsort()+10, new Text()), 'new'));
$form->addHTML('
');
$form->addButton('save', 'Save')->attr('type','submit');
return $form->toHTML();
}
/**
* Returns the HTML to edit a single column definition of the schema
*
* @param string $column_id
* @param Column $col
* @param string $key The key to use in the form
* @return string
* @todo this should probably be reused for adding new columns via AJAX later?
*/
protected function adminColumn($column_id, Column $col, $key='cols') {
$base = 'schema['.$key.'][' . $column_id . ']'; // base name for all fields
$html = '