template updates - htmx on categories form
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
echo $this->Form->control('product_catalog_id', ['options' => $productCatalogs]);
|
||||
echo $this->Form->control('base_url');
|
||||
echo $this->Form->control('api_url');
|
||||
echo $this->Form->control('deleted', ['empty' => true]);
|
||||
echo $this->Form->control('enabled');
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
echo $this->Form->control('product_catalog_id', ['options' => $productCatalogs]);
|
||||
echo $this->Form->control('base_url');
|
||||
echo $this->Form->control('api_url');
|
||||
echo $this->Form->control('deleted', ['empty' => true]);
|
||||
echo $this->Form->control('enabled');
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
@@ -18,13 +18,7 @@
|
||||
<?= $this->Form->create($productCategory) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Add Product Category') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->control('product_catalog_id', ['options' => $productCatalogs]);
|
||||
echo $this->Form->control('name');
|
||||
echo $this->Form->control('category_description');
|
||||
echo $this->Form->control('parent_id', ['options' => $parentProductCategories, 'empty' => true]);
|
||||
echo $this->Form->control('enabled');
|
||||
?>
|
||||
<?= $this->element('ProductCategories/form'); ?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
|
||||
@@ -23,13 +23,7 @@
|
||||
<?= $this->Form->create($productCategory) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Edit Product Category') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->control('product_catalog_id', ['options' => $productCatalogs]);
|
||||
echo $this->Form->control('name');
|
||||
echo $this->Form->control('category_description');
|
||||
echo $this->Form->control('parent_id', ['options' => $parentProductCategories, 'empty' => true]);
|
||||
echo $this->Form->control('enabled');
|
||||
?>
|
||||
<?= $this->element('ProductCategories/form'); ?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
|
||||
13
templates/ProductCategories/select.php
Normal file
13
templates/ProductCategories/select.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var iterable<\Cake\Datasource\EntityInterface> $productCategories
|
||||
*/
|
||||
|
||||
$this->setLayout('ajax');
|
||||
|
||||
?>
|
||||
<option value="">Select a parent (optional)</option>
|
||||
<?php foreach ($productCategories as $productCategoryId => $productCategoryName): ?>
|
||||
<option value="<?= $productCategoryId; ?>" <?= $this->request->getQuery('category_id') == $productCategoryId ? 'selected="selected"' : ''; ?>><?= $productCategoryName; ?></option>
|
||||
<?php endforeach; ?>
|
||||
30
templates/element/ProductCategories/form.php
Normal file
30
templates/element/ProductCategories/form.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \Cake\Datasource\EntityInterface $productCategory
|
||||
* @var \Cake\Collection\CollectionInterface|string[] $productCatalogs
|
||||
* @var string|null $prefix
|
||||
*/
|
||||
|
||||
echo $this->Form->control('product_catalog_id', [
|
||||
'options' => $productCatalogs,
|
||||
'hx-trigger' => 'change, load delay:1s',
|
||||
'hx-get' => $this->Url->build([
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategories',
|
||||
'action' => 'select',
|
||||
'?' => [
|
||||
'category_id' => $productCategory->parent_id ?? '',
|
||||
],
|
||||
]),
|
||||
'hx-target' => '#product_category_parent_id',
|
||||
]);
|
||||
echo $this->Form->control('name');
|
||||
echo $this->Form->control('category_description');
|
||||
echo $this->Form->control('parent_id', [
|
||||
'options' => $parentProductCategories,
|
||||
'empty' => true,
|
||||
'id' => 'product_category_parent_id',
|
||||
]);
|
||||
echo $this->Form->control('enabled');
|
||||
?>
|
||||
Reference in New Issue
Block a user