| @@ -15,8 +15,11 @@ | ||
| 15 | 15 | private $_fieldHelpers; |
| 16 | 16 | |
| 17 | 17 | public function __construct($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) |
| 18 | 18 | { |
| 19 | + // Corrupt/partial form JSON can hand us a null field; normalize so | |
| 20 | + // property_exists() calls never receive null (PHP 8 TypeError). | |
| 21 | + $field = is_object($field) ? $field : new \stdClass(); | |
| 19 | 22 | $this->_fieldData = $field; |
| 20 | 23 | $this->_fieldKey = $rowID; |
| 21 | 24 | $this->_fieldName = $field_name; |
| 22 | 25 | $this->_formID = $formID; |
| @@ -29,19 +32,21 @@ | ||
| 29 | 32 | { |
| 30 | 33 | $labelWrapper = !$noLabel ? $this->labelWrapper() : ''; |
| 31 | 34 | $helperText = $this->helperText(); |
| 32 | 35 | $error = !$noErrMsg ? $this->errorMessages() : ''; |
| 36 | + $fieldTypeClass = empty($this->_fieldData->typ) ? 'bf-default-field' : 'bf-' . $this->_fieldData->typ . '-field'; | |
| 33 | 37 | |
| 34 | 38 | return sprintf( |
| 35 | - '<div %1$s class="%2$s %3$s"> | |
| 36 | - %4$s | |
| 37 | - <div %5$s class="%6$s %7$s"> | |
| 38 | - %8$s | |
| 39 | - %9$s | |
| 40 | - %10$s | |
| 41 | - </div> | |
| 42 | -</div>', | |
| 39 | + '<div %1$s class="%2$s %3$s %4$s"> | |
| 40 | + %5$s | |
| 41 | + <div %6$s class="%7$s %8$s"> | |
| 42 | + %9$s | |
| 43 | + %10$s | |
| 44 | + %11$s | |
| 45 | + </div> | |
| 46 | + </div>', | |
| 43 | 47 | $this->_fieldHelpers->getCustomAttributes('fld-wrp'), |
| 48 | + $fieldTypeClass, | |
| 44 | 49 | $this->_fieldHelpers->getAtomicCls('fld-wrp'), |
| 45 | 50 | $this->_fieldHelpers->getCustomClasses('fld-wrp'), |
| 46 | 51 | $labelWrapper, |
| 47 | 52 | $this->_fieldHelpers->getCustomAttributes('inp-wrp'), |
| @@ -142,9 +147,9 @@ | ||
| 142 | 147 | ); |
| 143 | 148 | } |
| 144 | 149 | |
| 145 | 150 | // for subtitle |
| 146 | - if (property_exists($this->_fieldData, 'subtitle') && $this->_fieldData->subtitleHide) { | |
| 151 | + if (property_exists($this->_fieldData, 'subtitle') && !empty($this->_fieldData->subtitleHide)) { | |
| 147 | 152 | $_subtitle = sprintf( |
| 148 | 153 | '<div %1$s class="%2$s %3$s">%4$s%5$s%6$s</div>', |
| 149 | 154 | $this->_fieldHelpers->getCustomAttributes('sub-titl'), |
| 150 | 155 | $this->_fieldHelpers->getAtomicCls('sub-titl'), |
| @@ -283,13 +288,20 @@ | ||
| 283 | 288 | . $childFieldsInput |
| 284 | 289 | . '</div>'; |
| 285 | 290 | } |
| 286 | 291 | |
| 287 | - public function childFieldWrapper($fieldInput) | |
| 292 | + public function childFieldWrapper($fieldInput, $subFieldName = '', $colSpan = null, $childKey = '') | |
| 288 | 293 | { |
| 289 | - return '<div ' | |
| 294 | + $dataAttr = $subFieldName ? ' data-bf-subfield="' . esc_attr($subFieldName) . '"' : ''; | |
| 295 | + $styleAttr = null !== $colSpan ? ' style="--bfv-addr-col:' . (int) $colSpan . '"' : ''; | |
| 296 | + // Per-child class so conditional actions (show/hide) can collapse the whole column. | |
| 297 | + $childKeyCls = $childKey ? ' ' . esc_attr($childKey) . '-sub-fld-wrp' : ''; | |
| 298 | + return '<div' | |
| 299 | + . $dataAttr | |
| 300 | + . $styleAttr | |
| 301 | + . ' ' | |
| 290 | 302 | . $this->_fieldHelpers->getCustomAttributes('child-fld-wrp') |
| 291 | - . ' class="' . $this->_fieldHelpers->getAtomicCls('child-fld-wrp') . ' ' . $this->_fieldHelpers->getCustomClasses('child-fld-wrp') . '">' | |
| 303 | + . ' class="' . $this->_fieldHelpers->getAtomicCls('child-fld-wrp') . ' ' . $this->_fieldHelpers->getCustomClasses('child-fld-wrp') . $childKeyCls . '">' | |
| 292 | 304 | . $fieldInput |
| 293 | 305 | . '</div>'; |
| 294 | 306 | } |
| 295 | 307 | } |