function setData($value) { if ($value != $this->valueOnCheck) { if ($value == 'on') { $value = $this->valueOnCheck; } else { $value = $this->valueOnUncheck; } } parent::setData($value); }
/** * declare a child control to the form. The given control should be a child of an other control * @param jFormsControl $control */ public function addChildControl($control) { $this->controls[$control->ref] = $control; if ($control->type == 'submit') { $this->submits[$control->ref] = $control; } else { if ($control->type == 'reset') { $this->reset = $control; } else { if ($control->type == 'upload') { $this->uploads[$control->ref] = $control; } else { if ($control->type == 'hidden') { $this->hiddens[$control->ref] = $control; } else { if ($control->type == 'htmleditor') { $this->htmleditors[$control->ref] = $control; } } } } } $control->setForm($this); if (!isset($this->container->data[$control->ref])) { if ($control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { $dt = new jDateTime(); $dt->now(); $this->container->data[$control->ref] = $dt->toString($control->datatype->getFormat()); } else { $this->container->data[$control->ref] = $control->defaultValue; } } }
/** * @param jFormsControl $ctrl */ protected function commonJs($ctrl) { if ($ctrl->isReadOnly()) { $this->jsContent .= "c.readOnly = true;\n"; } if ($ctrl->required) { $this->jsContent .= "c.required = true;\n"; if ($ctrl->alertRequired) { $this->jsContent .= "c.errRequired=" . $this->escJsStr($ctrl->alertRequired) . ";\n"; } else { $this->jsContent .= "c.errRequired=" . $this->escJsStr(jLocale::get('jelix~formserr.js.err.required', $ctrl->label)) . ";\n"; } } if ($ctrl->alertInvalid) { $this->jsContent .= "c.errInvalid=" . $this->escJsStr($ctrl->alertInvalid) . ";\n"; } else { $this->jsContent .= "c.errInvalid=" . $this->escJsStr(jLocale::get('jelix~formserr.js.err.invalid', $ctrl->label)) . ";\n"; } if ($this->isRootControl) { $this->jsContent .= $this->jFormsJsVarName . ".tForm.addControl(c);\n"; } }
/** * @param jFormsControl $ctrl */ protected function commonJs($ctrl) { if ($ctrl->isReadOnly()) { $this->jsContent .= "c.readOnly = true;\n"; } if ($ctrl->required) { $this->jsContent .= "c.required = true;\n"; if ($ctrl->alertRequired) { $this->jsContent .= "c.errRequired=" . $this->escJsStr($ctrl->alertRequired) . ";\n"; } else { $this->jsContent .= "c.errRequired=" . $this->escJsStr(jLocale::get('jelix~formserr.js.err.required', $ctrl->label)) . ";\n"; } } if ($ctrl->alertInvalid) { $this->jsContent .= "c.errInvalid=" . $this->escJsStr($ctrl->alertInvalid) . ";\n"; } else { $this->jsContent .= "c.errInvalid=" . $this->escJsStr(jLocale::get('jelix~formserr.js.err.invalid', $ctrl->label)) . ";\n"; } if ($this->isRootControl) { $this->jsContent .= "jFormsJQ.tForm.addControl(c);\n"; } if ($ctrl instanceof jFormsControlDate || get_class($ctrl->datatype) == 'jDatatypeDate' || get_class($ctrl->datatype) == 'jDatatypeLocaleDate') { $config = isset($ctrl->datepickerConfig) ? $ctrl->datepickerConfig : jApp::config()->forms['datepicker']; $this->jsContent .= 'jelix_datepicker_' . $config . "(c, jFormsJQ.config);\n"; } }