[], $prefix ? $prefix . 'contact_name' : 'contact_name' => [], $prefix ? $prefix . 'address_line1' : 'address_line1' => [], $prefix ? $prefix . 'address_line2' : 'address_line2' => [], $prefix ? $prefix . 'city' : 'city' => [], $prefix ? $prefix . 'city_id' : 'city_id' => [ 'hidden' => true, 'options' => $cities ?? [], 'empty' => true ], $prefix ? $prefix . 'state_id' : 'state_id' => [ 'options' => $states ?? [], 'id' => $stateIdId, 'empty' => 'Select a state', 'default' => $address->state_id ?? '', 'value' => $address->state_id ?? '', ], $prefix ? $prefix . 'postal_code' : 'postal_code' => [], $prefix ? $prefix . 'country_id' : 'country_id' => [ 'options' => $countries, 'empty' => 'Select a country', 'default' => 233, 'hx-trigger' => isset($address->id) ? 'change' : 'change, load delay:1s', 'hx-get' => $this->Url->build([ 'plugin' => 'CakeAddresses', 'controller' => 'States', 'action' => 'select', '?' => [ 'state_id' => $address->state_id ?? '', ], ]), 'hx-target' => '#' . $stateIdId, // 'hx-indicator' => '.htmx-indicator', ], $prefix ? $prefix . 'phone_number' : 'phone_number' => [], $prefix ? $prefix . 'email' : 'email' => [], $prefix ? $prefix . 'notes' : 'notes' => [], ]; foreach ($inputs as $inputName => $inputOptions) { if (array_key_exists('hidden', $inputOptions) && $inputOptions['hidden']) { echo $this->Form->hidden($inputName, $inputOptions); } if (!array_key_exists('hidden', $inputOptions) || !$inputOptions['hidden']) { echo $this->Form->control($inputName, $inputOptions); } } ?>