Current Path : /data/web/virtuals/51568/virtual/www/subdom/srps/src/form/ |
Current File : /data/web/virtuals/51568/virtual/www/subdom/srps/src/form/Form.php |
<?php namespace app\form; use app\Model; class Form { public static function begin($action, $method, $id, $onsubmit = '') { $onsubmit = ($onsubmit) ? 'onsubmit="return ' . $onsubmit . '()"' : ''; echo \sprintf ('<form id="form' . $id . '" action="%s" method="%s" %s>', $action, $method, $onsubmit); return new Form(); } public static function end(Model $model, $javaScript = true) { if ($javaScript) { echo "</form> <script>" . $model->rulesJSON() . '; ' . $model->typesJSON() . '; ' . $model->errorMessagesJSON() . '; ' . $model->specialErrorMessagesJSON() . '; ' . "</script>"; } else { echo "</form>"; } } public function field(Model $model, $attribute) { return new InputField($model, $attribute); } public function hidden(Model $model, $attribute) { return new HiddenField($model, $attribute); } public function textarea(Model $model, $attribute) { return new TextareaField($model, $attribute); } public function checkbox(Model $model, $attribute, $state) { return new CheckboxField($model, $attribute, $state); } public function radiogroup(Model $model, $attribute, array $radios, string $value, bool $inline) { return new RadiogroupField($model, $attribute, $radios, $value, $inline); } public function select(Model $model, $attribute, array $select, string $value) { return new SelectField($model, $attribute, $select, $value); } public function checkboxgroup(Model $model, $attribute, array $select, array $value) { return new CheckboxgroupField($model, $attribute, $select, $value); } } // class="requires-validation"