@@ 105-143 (lines=39) @@ | ||
102 | { |
|
103 | $output = ''; |
|
104 | ||
105 | foreach ($fields as $f) { |
|
106 | $ucF = ucfirst($f); |
|
107 | ||
108 | $input_attr = [ |
|
109 | 'class' => 'form-control', |
|
110 | 'id' => 'createItem'.$f, |
|
111 | 'name' => $f, |
|
112 | ]; |
|
113 | ||
114 | $output .= '<fieldset class="form-group">'; |
|
115 | ||
116 | $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
117 | ||
118 | if ($this->isIdField($f)) { |
|
119 | $input_attr['type'] = 'select'; |
|
120 | ||
121 | $output .= '<select '; |
|
122 | foreach ($input_attr as $attr => $value) { |
|
123 | $output .= "{$attr}='{$value}'"; |
|
124 | } |
|
125 | ||
126 | $relation = $this->crudApi->getRelatedModel($f); |
|
127 | $output .= '>'; |
|
128 | ||
129 | $output .= $this->crudApi->getRelatedOptions($relation); |
|
130 | ||
131 | $output .= '</select>'; |
|
132 | } else { |
|
133 | $input_attr['type'] = 'text'; |
|
134 | ||
135 | $output .= '<input '; |
|
136 | foreach ($input_attr as $attr => $value) { |
|
137 | $output .= "{$attr}='{$value}'"; |
|
138 | } |
|
139 | $output .= '>'; |
|
140 | } |
|
141 | ||
142 | $output .= '</fieldset>'; |
|
143 | } |
|
144 | ||
145 | return $output; |
|
146 | } |
@@ 166-203 (lines=38) @@ | ||
163 | $output .= $this->fieldHelper->formCreate($fields); |
|
164 | break; |
|
165 | case 'form-edit': |
|
166 | foreach ($fields as $f) { |
|
167 | $ucF = ucfirst($f); |
|
168 | ||
169 | $input_attr = [ |
|
170 | 'class' => 'form-control', |
|
171 | 'id' => 'editItem'.$ucF, |
|
172 | 'name' => $f, |
|
173 | ]; |
|
174 | ||
175 | $output .= '<fieldset class="form-group">'; |
|
176 | ||
177 | $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
178 | ||
179 | if ($this->fieldHelper->isIdField($f)) { |
|
180 | $input_attr['type'] = 'select'; |
|
181 | ||
182 | $output .= '<select '; |
|
183 | foreach ($input_attr as $attr => $value) { |
|
184 | $output .= "{$attr}='{$value}'"; |
|
185 | } |
|
186 | ||
187 | $relation = $this->getRelatedModel($f); |
|
188 | $output .= '>'; |
|
189 | ||
190 | $output .= $this->getRelatedOptions($relation); |
|
191 | $output .= '</select>'; |
|
192 | } else { |
|
193 | $input_attr['type'] = 'text'; |
|
194 | ||
195 | $output .= '<input '; |
|
196 | foreach ($input_attr as $attr => $value) { |
|
197 | $output .= "{$attr}='{$value}'"; |
|
198 | } |
|
199 | $output .= '>'; |
|
200 | } |
|
201 | ||
202 | $output .= '</fieldset>'; |
|
203 | } |
|
204 | break; |
|
205 | case 'table-headings': |
|
206 | $output .= $this->fieldHelper->tableHeadings($fields); |