subscribtion category variants / system category variants

This commit is contained in:
2025-11-04 01:50:05 -08:00
parent 868f9dbcce
commit a471be8ff9
13 changed files with 254 additions and 12 deletions

View File

@@ -18,7 +18,7 @@
<?= $this->Form->create($productCategoryVariant) ?>
<fieldset>
<legend><?= __('Add Product Category Variant') ?></legend>
<?= $this->element('ProductCategoryVariants/form'); ?>
<?= $this->element('ProductCategoryVariants/form', ['productCategoryVariant' => $productCategoryVariant]); ?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>

View File

@@ -23,7 +23,7 @@
<?= $this->Form->create($productCategoryVariant) ?>
<fieldset>
<legend><?= __('Edit Product Category Variant') ?></legend>
<?= $this->element('ProductCategoryVariants/form'); ?>
<?= $this->element('ProductCategoryVariants/form', ['productCategoryVariant' => $productCategoryVariant]); ?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>

View File

@@ -26,7 +26,6 @@
<th><?= __('Id') ?></th>
<td><?= h($productPhoto->id) ?></td>
</tr>
<tr>
<th><?= __('Product Category') ?></th>
<td><?= $productPhoto->hasValue('product_category') ? $this->Html->link($productPhoto->product_category->name, ['controller' => 'ProductCategories', 'action' => 'view', $productPhoto->product_category->internal_id]) : '' ?></td>

View File

@@ -2,11 +2,30 @@
/**
* @var array $productCategories
* @var array $products
* @var \CakeProducts\Model\Entity\ProductCategoryVariant|\Cake\Datasource\EntityInterface $productCategoryVariant
*/
echo $this->Form->control('name');
echo $this->Form->control('product_category_id', ['options' => $productCategories, 'empty' => true]);
echo $this->Form->control('product_id', ['options' => $products, 'empty' => true]);
echo $this->Form->control('enabled');
$nameOptions = [];
$categoryOptions = ['options' => $productCategories, 'empty' => true];
$enabledOptions = [];
if ($productCategoryVariant->is_system_variant) {
$nameOptions = [
'disabled' => true,
'readonly' => true,
];
$categoryOptions = $categoryOptions + [
'disabled' => true,
'readonly' => true,
];
$enabledOptions = [
'disabled' => true,
'readonly' => true,
];
}
echo $this->Form->control('name', $nameOptions);
echo $this->Form->control('product_category_id', $categoryOptions);
echo $this->Form->control('enabled', $enabledOptions);
?>
<legend><?= __('Variant Options') . '<small class="ms-2">' . $this->Html->link('Add Option', '#', [
'id' => 'add-option-button',