| @@ 335-372 (lines=38) @@ | ||
| 332 | * |
|
| 333 | * @since 1.0 |
|
| 334 | */ |
|
| 335 | public function getFieldset($set = null) |
|
| 336 | { |
|
| 337 | $fields = array(); |
|
| 338 | ||
| 339 | // Get all of the field elements in the fieldset. |
|
| 340 | if ($set) |
|
| 341 | { |
|
| 342 | $elements = $this->findFieldsByFieldset($set); |
|
| 343 | } |
|
| 344 | else |
|
| 345 | // Get all fields. |
|
| 346 | { |
|
| 347 | $elements = $this->findFieldsByGroup(); |
|
| 348 | } |
|
| 349 | ||
| 350 | // If no field elements were found return empty. |
|
| 351 | if (empty($elements)) |
|
| 352 | { |
|
| 353 | return $fields; |
|
| 354 | } |
|
| 355 | ||
| 356 | // Build the result array from the found field elements. |
|
| 357 | foreach ($elements as $element) |
|
| 358 | { |
|
| 359 | // Get the field groups for the element. |
|
| 360 | $attrs = $element->xpath('ancestor::fields[@name]/@name'); |
|
| 361 | $groups = array_map('strval', $attrs ? $attrs : array()); |
|
| 362 | $group = implode('.', $groups); |
|
| 363 | ||
| 364 | // If the field is successfully loaded add it to the result array. |
|
| 365 | if ($field = $this->loadField($element, $group)) |
|
| 366 | { |
|
| 367 | $fields[$field->id] = $field; |
|
| 368 | } |
|
| 369 | } |
|
| 370 | ||
| 371 | return $fields; |
|
| 372 | } |
|
| 373 | ||
| 374 | /** |
|
| 375 | * Method to get an array of fieldset objects optionally filtered over a given field group. |
|
| @@ 502-531 (lines=30) @@ | ||
| 499 | * |
|
| 500 | * @since 1.0 |
|
| 501 | */ |
|
| 502 | public function getGroup($group, $nested = false) |
|
| 503 | { |
|
| 504 | $fields = array(); |
|
| 505 | ||
| 506 | // Get all of the field elements in the field group. |
|
| 507 | $elements = $this->findFieldsByGroup($group, $nested); |
|
| 508 | ||
| 509 | // If no field elements were found return empty. |
|
| 510 | if (empty($elements)) |
|
| 511 | { |
|
| 512 | return $fields; |
|
| 513 | } |
|
| 514 | ||
| 515 | // Build the result array from the found field elements. |
|
| 516 | foreach ($elements as $element) |
|
| 517 | { |
|
| 518 | // Get the field groups for the element. |
|
| 519 | $attrs = $element->xpath('ancestor::fields[@name]/@name'); |
|
| 520 | $groups = array_map('strval', $attrs ? $attrs : array()); |
|
| 521 | $group = implode('.', $groups); |
|
| 522 | ||
| 523 | // If the field is successfully loaded add it to the result array. |
|
| 524 | if ($field = $this->loadField($element, $group)) |
|
| 525 | { |
|
| 526 | $fields[$field->id] = $field; |
|
| 527 | } |
|
| 528 | } |
|
| 529 | ||
| 530 | return $fields; |
|
| 531 | } |
|
| 532 | ||
| 533 | /** |
|
| 534 | * Method to get a form field markup for the field input. |
|