Skip to content

Commit

Permalink
Added icon for fieldtype
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfmorton committed Apr 8, 2024
1 parent 8a8f049 commit 30d872a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions src/fields/QRCodeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public static function displayName(): string
return Craft::t('qrcode', 'QR Code');
}

/**
* @inheritdoc
*/
public static function icon(): string
{
return __DIR__ . '/../assetbundles/qrcodefieldfield/dist/img/qrcode-fieldtype-icon.svg';
}

// Public Methods
// =========================================================================

Expand All @@ -59,11 +67,10 @@ public static function displayName(): string
public function rules(): array
{
$rules = parent::rules();
$rules = array_merge($rules, [
return array_merge($rules, [
['property', 'string'],
['property', 'required'],
]);
return $rules;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/templates/_components/fields/QRCodeField_settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

{{ forms.textareaField({
label: "Data Format"|t,
instructions: ""|t,
instructions: "Define the format of the a QR code to be shown in the control panel. Use Twig to dynamically retrieve properties of the element that the fieldtype is set on. It may be a simple string, i.e. `{{ entry.title }}`, or a full JSON string, i.e., `{ \"title\" : \"{{ entry.title }}\" }`."|t,
id: 'property',
name: 'property',
class: 'code',
required: true,
value: field.property ? field.property|raw,
errors: field.getErrors('property'),
rows: 8
rows: 6
}) }}

0 comments on commit 30d872a

Please sign in to comment.