phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
BusinessForm.php
Go to the documentation of this file.
1 <?php
2 
4 
6 use Ajax\JsUtils;
7 
11 abstract class BusinessForm extends DataForm {
12  protected $_fieldsOrder;
19  public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) {
20  if(!isset($modelInstance)){
21  $modelInstance=$this->getDefaultModelInstance();
22  }
23  parent::__construct($identifier,$modelInstance);
24  $this->_initForm($fieldsOrder, $fieldsDefinition,$fields,$captions,$separators);
25  }
26 
27  abstract protected function getDefaultModelInstance();
28 
29  protected function _initForm($fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]){
30  $this->_fieldsOrder=$fieldsOrder;
31  $this->setFields($fields);
32  $this->setSeparators($separators);
33  $this->fieldsAs($fieldsDefinition);
34  $this->setCaptions($captions);
35  }
36 
37  protected function _getIndex($fieldName){
38  $index=$fieldName;
39  if(\is_string($fieldName)){
40  $index=\array_search($fieldName, $this->_fieldsOrder);
41  }
42  return $index;
43  }
44  protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){
45  $index=$this->_getIndex($index);
46  return parent::_fieldAs($elementCallback, $index,$attributes,$prefix);
47  }
48 
49 
50  public function removeField($fieldName){
51  parent::removeField($fieldName);
52  \array_splice($this->_fieldsOrder,$this->_getIndex($fieldName),1);
53  return $this;
54  }
55 
56  public function compile(JsUtils $js=NULL,&$view=NULL){
57  return parent::compile($js,$view);
58  }
59 }
setFields($fields)
Definition: Widget.php:183
_initForm($fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[])
fieldsAs(array $types)
Change fields type.
_fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null)
JQuery PHP library.
Definition: JsUtils.php:23
_fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null)
compile(JsUtils $js=NULL, &$view=NULL)
setCaptions($captions)
Definition: Widget.php:173
__construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[])
{}