Skip to content

Commit

Permalink
Undefined index: customFields error is now resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-adigital committed Jul 26, 2018
1 parent 972fd89 commit 5d4d41a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"pluginName":"Zendesk","pluginDescription":"Creates a new support ticket in Zendesk using the JSON API","pluginVersion":"1.0.3","pluginAuthorName":"Matt Shearing","pluginVendorName":"a-digital","pluginAuthorUrl":"https://adigital.agency","pluginAuthorGithub":"","codeComments":"yes","pluginComponents":["controllers","services","settings","widgets"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
{"pluginName":"Zendesk","pluginDescription":"Creates a new support ticket in Zendesk using the JSON API","pluginVersion":"1.0.4","pluginAuthorName":"Matt Shearing","pluginVendorName":"a-digital","pluginAuthorUrl":"https://adigital.agency","pluginAuthorGithub":"","codeComments":"yes","pluginComponents":["controllers","services","settings","widgets"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Zendesk Changelog

## 1.0.4 - 2018-07-26
### Fixed
- Undefined index: customFields error is now resolved

## 1.0.3 - 2018-07-02
### Added
- File upload functionality added to dashboard widget
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "adigital/zendesk",
"description": "Creates a new support ticket in Zendesk using the JSON API",
"type": "craft-plugin",
"version": "1.0.3",
"version": "1.0.4",
"keywords": [
"craft",
"cms",
Expand Down
52 changes: 27 additions & 25 deletions src/templates/_components/widgets/ZendeskWidget_body.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,33 @@
value: ''})
}}

{% for customField in customFields %}
{% if customField["fieldType"] == "select" %}
{% set customOptions = {} %}
{% for option in customField["fieldValues"] %}
{% set optionValue = option["value"] %}
{% set optionLabel = option["label"] %}
{% set customOptions = customOptions|merge({ (option.value): option.label }) %}
{% endfor %}
{{ forms.selectField({
label: customField["fieldLabel"],
name: customField["fieldName"],
options: customOptions,
value: ''})
}}
{% elseif customField["fieldType"] == "text" %}
{{ forms.textField({
label: customField["fieldLabel"],
placeholder: 'Enter your subject here.',
name: customField["fieldName"],
value: ''})
}}
{% elseif customField["fieldType"] == "hidden" %}
<input type="hidden" name="{{ customField["fieldName"] }}" id="{{ customField["fieldName"] }}" value="{{ customField["fieldValue"] }}" />
{% endif %}
{% endfor %}
{% if customFields is defined %}
{% for customField in customFields %}
{% if customField["fieldType"] == "select" %}
{% set customOptions = {} %}
{% for option in customField["fieldValues"] %}
{% set optionValue = option["value"] %}
{% set optionLabel = option["label"] %}
{% set customOptions = customOptions|merge({ (option.value): option.label }) %}
{% endfor %}
{{ forms.selectField({
label: customField["fieldLabel"],
name: customField["fieldName"],
options: customOptions,
value: ''})
}}
{% elseif customField["fieldType"] == "text" %}
{{ forms.textField({
label: customField["fieldLabel"],
placeholder: 'Enter your subject here.',
name: customField["fieldName"],
value: ''})
}}
{% elseif customField["fieldType"] == "hidden" %}
<input type="hidden" name="{{ customField["fieldName"] }}" id="{{ customField["fieldName"] }}" value="{{ customField["fieldValue"] }}" />
{% endif %}
{% endfor %}
{% endif %}

{{ forms.textField({
label: 'Subject',
Expand Down
15 changes: 9 additions & 6 deletions src/widgets/ZendeskWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,17 @@ public function getSettingsHtml()
public function getBodyHtml()
{
Craft::$app->getView()->registerAssetBundle(ZendeskWidgetWidgetAsset::class);

$widgetOptions = [
'name' => $this->name,
'email' => $this->email
];
if (Craft::$app->getConfig()->getConfigFromFile("zendesk")) {
$widgetOptions['customFields'] = Craft::$app->getConfig()->getConfigFromFile("zendesk")["customFields"];
}

return Craft::$app->getView()->renderTemplate(
'zendesk/_components/widgets/ZendeskWidget_body',
[
'name' => $this->name,
'email' => $this->email,
'customFields' => Craft::$app->getConfig()->getConfigFromFile("zendesk")["customFields"]
]
$widgetOptions
);
}
}

0 comments on commit 5d4d41a

Please sign in to comment.