| @@ 156-196 (lines=41) @@ | ||
| 153 | $output = ''; |
|
| 154 | ||
| 155 | switch ($type) { |
|
| 156 | case 'form-create': |
|
| 157 | foreach ($fields as $f) { |
|
| 158 | $ucF = ucfirst($f); |
|
| 159 | ||
| 160 | $input_attr = [ |
|
| 161 | 'class' => 'form-control', |
|
| 162 | 'id' => 'createItem'.$f, |
|
| 163 | 'name' => $f, |
|
| 164 | ]; |
|
| 165 | ||
| 166 | $output .= '<fieldset class="form-group">'; |
|
| 167 | ||
| 168 | $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
| 169 | ||
| 170 | if ($this->fieldHelper->isIdField($f)) { |
|
| 171 | $input_attr['type'] = 'select'; |
|
| 172 | ||
| 173 | $output .= '<select '; |
|
| 174 | foreach ($input_attr as $attr => $value) { |
|
| 175 | $output .= "{$attr}='{$value}'"; |
|
| 176 | } |
|
| 177 | ||
| 178 | $relation = $this->getRelatedModel($f); |
|
| 179 | $output .= '>'; |
|
| 180 | ||
| 181 | $output .= $this->getRelatedOptions($relation); |
|
| 182 | ||
| 183 | $output .= '</select>'; |
|
| 184 | } else { |
|
| 185 | $input_attr['type'] = 'text'; |
|
| 186 | ||
| 187 | $output .= '<input '; |
|
| 188 | foreach ($input_attr as $attr => $value) { |
|
| 189 | $output .= "{$attr}='{$value}'"; |
|
| 190 | } |
|
| 191 | $output .= '>'; |
|
| 192 | } |
|
| 193 | ||
| 194 | $output .= '</fieldset>'; |
|
| 195 | } |
|
| 196 | break; |
|
| 197 | case 'form-edit': |
|
| 198 | foreach ($fields as $f) { |
|
| 199 | $ucF = ucfirst($f); |
|
| @@ 197-236 (lines=40) @@ | ||
| 194 | $output .= '</fieldset>'; |
|
| 195 | } |
|
| 196 | break; |
|
| 197 | case 'form-edit': |
|
| 198 | foreach ($fields as $f) { |
|
| 199 | $ucF = ucfirst($f); |
|
| 200 | ||
| 201 | $input_attr = [ |
|
| 202 | 'class' => 'form-control', |
|
| 203 | 'id' => 'editItem'.$ucF, |
|
| 204 | 'name' => $f, |
|
| 205 | ]; |
|
| 206 | ||
| 207 | $output .= '<fieldset class="form-group">'; |
|
| 208 | ||
| 209 | $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>'; |
|
| 210 | ||
| 211 | if ($this->fieldHelper->isIdField($f)) { |
|
| 212 | $input_attr['type'] = 'select'; |
|
| 213 | ||
| 214 | $output .= '<select '; |
|
| 215 | foreach ($input_attr as $attr => $value) { |
|
| 216 | $output .= "{$attr}='{$value}'"; |
|
| 217 | } |
|
| 218 | ||
| 219 | $relation = $this->getRelatedModel($f); |
|
| 220 | $output .= '>'; |
|
| 221 | ||
| 222 | $output .= $this->getRelatedOptions($relation); |
|
| 223 | $output .= '</select>'; |
|
| 224 | } else { |
|
| 225 | $input_attr['type'] = 'text'; |
|
| 226 | ||
| 227 | $output .= '<input '; |
|
| 228 | foreach ($input_attr as $attr => $value) { |
|
| 229 | $output .= "{$attr}='{$value}'"; |
|
| 230 | } |
|
| 231 | $output .= '>'; |
|
| 232 | } |
|
| 233 | ||
| 234 | $output .= '</fieldset>'; |
|
| 235 | } |
|
| 236 | break; |
|
| 237 | case 'table-headings': |
|
| 238 | foreach ($fields as $f) { |
|
| 239 | $output .= '<th>'.ucfirst($f).'</th>'; |
|