Code style fixes
This commit is contained in:
parent
6c4c669492
commit
0868eb9c69
63 changed files with 1413 additions and 1494 deletions
|
|
@ -1,106 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace b8\Form;
|
||||
use b8\Form\Element,
|
||||
b8\Form\Input,
|
||||
b8\View;
|
||||
|
||||
use b8\Form\Element, b8\View;
|
||||
|
||||
class FieldSet extends Element
|
||||
{
|
||||
protected $_children = array();
|
||||
protected $_children = [];
|
||||
|
||||
public function getValues()
|
||||
{
|
||||
$rtn = array();
|
||||
public function getValues()
|
||||
{
|
||||
$rtn = [];
|
||||
foreach ($this->_children as $field) {
|
||||
if ($field instanceof FieldSet) {
|
||||
$fieldName = $field->getName();
|
||||
|
||||
foreach($this->_children as $field)
|
||||
{
|
||||
if($field instanceof FieldSet)
|
||||
{
|
||||
$fieldName = $field->getName();
|
||||
if (empty($fieldName)) {
|
||||
$rtn = array_merge($rtn, $field->getValues());
|
||||
} else {
|
||||
$rtn[$fieldName] = $field->getValues();
|
||||
}
|
||||
} elseif ($field instanceof Input) {
|
||||
if ($field->getName()) {
|
||||
$rtn[$field->getName()] = $field->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($fieldName))
|
||||
{
|
||||
$rtn = array_merge($rtn, $field->getValues());
|
||||
}
|
||||
else
|
||||
{
|
||||
$rtn[$fieldName] = $field->getValues();
|
||||
}
|
||||
}
|
||||
elseif($field instanceof Input)
|
||||
{
|
||||
if($field->getName())
|
||||
{
|
||||
$rtn[$field->getName()] = $field->getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
public function setValues(array $values)
|
||||
{
|
||||
foreach ($this->_children as $field) {
|
||||
if ($field instanceof FieldSet) {
|
||||
$fieldName = $field->getName();
|
||||
|
||||
public function setValues(array $values)
|
||||
{
|
||||
foreach($this->_children as $field)
|
||||
{
|
||||
if($field instanceof FieldSet)
|
||||
{
|
||||
$fieldName = $field->getName();
|
||||
if (empty($fieldName) || !isset($values[$fieldName])) {
|
||||
$field->setValues($values);
|
||||
} else {
|
||||
$field->setValues($values[$fieldName]);
|
||||
}
|
||||
} elseif ($field instanceof Input) {
|
||||
$fieldName = $field->getName();
|
||||
|
||||
if(empty($fieldName) || !isset($values[$fieldName]))
|
||||
{
|
||||
$field->setValues($values);
|
||||
}
|
||||
else
|
||||
{
|
||||
$field->setValues($values[$fieldName]);
|
||||
}
|
||||
}
|
||||
elseif($field instanceof Input)
|
||||
{
|
||||
$fieldName = $field->getName();
|
||||
if (isset($values[$fieldName])) {
|
||||
$field->setValue($values[$fieldName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($values[$fieldName]))
|
||||
{
|
||||
$field->setValue($values[$fieldName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function addField(Element $field)
|
||||
{
|
||||
$this->_children[$field->getName()] = $field;
|
||||
$field->setParent($this);
|
||||
}
|
||||
|
||||
public function addField(Element $field)
|
||||
{
|
||||
$this->_children[$field->getName()] = $field;
|
||||
$field->setParent($this);
|
||||
}
|
||||
public function validate()
|
||||
{
|
||||
$rtn = true;
|
||||
|
||||
public function validate()
|
||||
{
|
||||
$rtn = true;
|
||||
foreach ($this->_children as $child) {
|
||||
if (!$child->validate()) {
|
||||
$rtn = false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->_children as $child)
|
||||
{
|
||||
if(!$child->validate())
|
||||
{
|
||||
$rtn = false;
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
protected function _onPreRender(View &$view)
|
||||
{
|
||||
$rendered = [];
|
||||
foreach ($this->_children as $child) {
|
||||
$rendered[] = $child->render();
|
||||
}
|
||||
|
||||
protected function _onPreRender(View &$view)
|
||||
{
|
||||
$rendered = array();
|
||||
|
||||
foreach($this->_children as $child)
|
||||
{
|
||||
$rendered[] = $child->render();
|
||||
}
|
||||
|
||||
$view->children = $rendered;
|
||||
}
|
||||
$view->children = $rendered;
|
||||
}
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue