Skip to content

Commit

Permalink
Fix Variants fields not persisting their “Source” setting
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Jul 15, 2023
1 parent 3410fc6 commit b4c4f67
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/fields/formfields/Variants.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static function getSvgIconPath(): string
// =========================================================================

public bool $searchable = true;
public bool $allowMultipleSources = false;

protected string $inputTemplate = 'formie/_includes/element-select-input';

Expand Down Expand Up @@ -112,8 +113,15 @@ public function getExtraBaseFieldConfig(): array
*/
public function getFieldDefaults(): array
{
$productType = null;
$productTypes = Commerce::getInstance()->getProductTypes()->getAllProductTypes();

if (!empty($productTypes)) {
$productType = 'productType:' . ArrayHelper::firstValue($productTypes)->uid;
}

return [
'source' => '*',
'source' => $productType,
'placeholder' => Craft::t('formie', 'Select a variant'),
'labelSource' => 'title',
'orderBy' => 'title ASC',
Expand Down

0 comments on commit b4c4f67

Please sign in to comment.