26 parent::__construct(
$identifier,
null,$modelInstance);
32 return $this->identifier.
"-{$name}-".$this->_instanceViewer->getIdentifier();
36 if(!$this->_generated){
37 $this->_instanceViewer->setInstance($this->_modelInstance);
39 $form=$this->content[
'form'];
42 if(isset($this->_toolbar)){
45 $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,
'form',PositionInTable::AFTERTABLE]);
47 $this->content[
'form']->setInverted(
true);
49 $this->_generated=
true;
51 return parent::compile($js,$view);
58 $values= $this->_instanceViewer->getValues();
59 $count=$this->_instanceViewer->count();
60 $separators=$this->_instanceViewer->getSeparators();
61 $headers=$this->_instanceViewer->getHeaders();
62 $wrappers=$this->_instanceViewer->getWrappers();
63 $names=$this->_instanceViewer->getProperties();
65 $size=\count($separators);
69 foreach ($values as $k=>$v){
70 $this->
_generateFields($form, [$v], $headers, $i, $wrappers,$nb++,$names[$k]??
'');
75 for($i=0;$i<$size;$i++){
76 $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]);
77 $this->
_generateFields($form, $fields, $headers, $separators[$i], $wrappers,$nb++,$names[$i]??
'');
80 if($this->_hasRules && !$this->
getForm()->hasValidationParams()){
85 protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb, $name){
87 if(isset($headers[$sepFirst+1]))
88 $form->addHeader($headers[$sepFirst+1],4,
true);
89 if(isset($wrappers[$sepFirst+1])){
90 $wrapper=$wrappers[$sepFirst+1];
92 $count=\count($values);
94 $added=$form->addField($values[0]);
96 $added=$form->addFields($values);
100 $added->wrap($wrapper[0],$wrapper[1]);
102 $this->
execHook(
'onGenerateFields',$added,$nb,$name);
111 $this->
addHook(
'onGenerateFields',$callback);
118 return $this->content[
'form'];
123 $this->_instanceViewer->addSeparatorAfter($fieldNum);
128 return $this->_instanceViewer->getSeparators();
132 $this->_instanceViewer->setSeparators($separators);
137 return $this->
_fieldAs(
function($id,$name,$value) use ($cssStyle){
139 $button->setProperty(
'type',
'reset');
141 }, $index,$attributes);
150 return $this->content[
'form'];
162 $this->_instanceViewer->addHeaderDividerBefore($index, $title);
166 public function addWrapper($index,$contentBefore,$contentAfter=
null){
168 $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter);
178 $this->_inverted=$recursive;
execHook($hookKey,... $variables)
Executes the hook with key $hookKey.
addHook($hookKey, $callable)
Adds a new Hook.