pfsense/usr/local/www/classes/Form/Section.class.php
Sjon Hortensius 69f9ff4034 final touches on Forms
system - removed trailing unused form-html
Form - set proper width for submit-button column
Element - support returning raw-list for Inputs
Group,Input - renamed getColumnWidth to getWidth
Input - make setWidth consistent with Form->setWidth, directly add
  proper class to column
2015-01-27 21:33:41 +01:00

53 lines
930 B
PHP

<?php
class Form_Section extends Form_Element
{
protected $_title;
protected $_groups = array();
public function __construct($title)
{
$this->_title = $title;
}
public function add(Form_Group $group)
{
array_push($this->_groups, $group);
$group->_setParent($this);
return $group;
}
// Shortcut, adds a group for the specified input
public function addInput(Form_Input $input)
{
$group = new Form_Group($input->getTitle());
$group->add($input);
$this->add($group);
return $input;
}
// Potentially allow overloading
public function getLabelWidth()
{
return $this->_parent->getLabelWidth();
}
public function __toString()
{
$title = gettext($this->_title);
$body = implode('', $this->_groups);
return <<<EOT
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{$title}</h2>
</div>
<div class="panel-body">{$body}</div>
</div>
EOT;
}
}