36 $this->
form =
factory::get(
'form_db', array_merge($this->cfg->formOpts, array(
37 'table'=>$this->cfg->table,
39 $this->replaceName = str_replace(
'[]',
'', $this->name).
'_fields['.$this->cfg->replaceKey.
'][[name]]';
40 foreach($this->cfg->fields as
$f) {
41 $f[
'name'] = str_replace(
'[name]', $f[
'name'], $this->replaceName);
42 $this->
form->addFromField($f);
46 $this->
valid->
getCfg()->setRef(
'value', $this->valuesForValid);
53 $this->valuesForValid = array();
55 if (is_array($value)) {
56 foreach($value as $v) {
57 $this->valuesForValid[] = $v[
db::getCfg(
'relatedValue')];
62 public function setValue($value, $refill=
false) {
67 if (is_array($tmpVal)) {
68 foreach($tmpVal as $v) {
72 foreach($this->cfg->fields as
$f) {
73 $curVal[$f[
'name']] = isset($vals[$v]) && isset($vals[$v][$f[
'name']]) ? $vals[$v][$f[
'name']] : null;
79 parent::setValue($value);
83 public function to($type) {
84 if ($type ==
'html' && $this->cfg->mode ==
'edit') {
87 return parent::to($type);
91 if ($this->cfg->mode ==
'view') {
93 if (is_array($this->cfg->value))
94 foreach($this->cfg->value as $v) {
96 foreach($v as $kk=>$vv) {
97 if ($kk !=
db::getCfg(
'relatedValue') && $vv) {
98 $tmp[] = $this->
form->
get(str_replace(
'[name]', $kk, $this->replaceName))->label.$this->cfg->sepLabelViewSubValues.$vv;
104 $line.=
' ('.implode($this->cfg->sepViewSubValues, $tmp).
')';
110 if (is_array($this->cfg->value))
111 foreach($this->cfg->value as $v) {
113 foreach($v as $k=>$vv) {
115 $form->setValue(str_replace(
'[name]', $k, $this->replaceName), $vv);
120 foreach($this->cfg->fields as
$f) {
121 $name = str_replace(
'[name]', $f[
'name'], $this->replaceName);
122 $form->get($name)->getCfg()->name = str_replace($this->cfg->replaceKey, $val, $name);
123 $form->get($name)->renew();
126 return str_replace(
'[fields]',
$form->__toString(), $line);
130 if (is_array($this->cfg->value))
131 foreach($this->cfg->value as $v) {
static get($className, array $cfg=array())