Skip to content

Commit

Permalink
Merged branch dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Hubert Prein committed Jul 13, 2016
2 parents 6d7293a + 1f59ba1 commit d3a43da
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 35 deletions.
20 changes: 18 additions & 2 deletions AmFormsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public function getReleaseFeedUrl()
*/
public function getVersion()
{
return '1.4.2';
return '1.4.3';
}

/**
* @return string
*/
public function getSchemaVersion()
{
return '1.4.2';
return '1.4.3';
}

/**
Expand Down Expand Up @@ -185,4 +185,20 @@ public function onBeforeUninstall()
// Delete content table
craft()->db->createCommand()->dropTable('amforms_content');
}

/**
* Add a&m flow event services.
*
* @return array
*/
public function addFlowEventServices()
{
return array(
array(
'name' => Craft::t('Submissions'),
'service' => 'amForms_submissions',
'model' => 'AmForms_SubmissionModel',
)
);
}
}
1 change: 1 addition & 0 deletions controllers/AmForms_FormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function actionSaveForm()
$form->afterSubmitText = craft()->request->getPost('afterSubmitText');
$form->submissionEnabled = craft()->request->getPost('submissionEnabled');
$form->displayTabTitles = craft()->request->getPost('displayTabTitles');
$form->redirectUrl = craft()->request->getPost('redirectUrl');
$form->sendCopy = craft()->request->getPost('sendCopy');
$form->sendCopyTo = craft()->request->getPost('sendCopyTo');
$form->notificationEnabled = craft()->request->getPost('notificationEnabled');
Expand Down
1 change: 1 addition & 0 deletions elementtypes/AmForms_FormElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $crit
forms.afterSubmitText,
forms.submissionEnabled,
forms.displayTabTitles,
forms.redirectUrl,
forms.sendCopy,
forms.sendCopyTo,
forms.notificationEnabled,
Expand Down
21 changes: 21 additions & 0 deletions migrations/m160509_142400_amforms_redirectUrl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Craft;

/**
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName.
*/
class m160509_142400_amforms_redirectUrl extends BaseMigration
{
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
$this->addColumnAfter('amforms_forms', 'redirectUrl', array(AttributeType::String), 'displayTabTitles');

return true;
}
}
1 change: 1 addition & 0 deletions models/AmForms_FormModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected function defineAttributes()
'afterSubmitText' => AttributeType::Mixed,
'submissionEnabled' => array(AttributeType::Bool, 'default' => true),
'displayTabTitles' => array(AttributeType::Bool, 'default' => false),
'redirectUrl' => AttributeType::String,
'sendCopy' => array(AttributeType::Bool, 'default' => false),
'sendCopyTo' => AttributeType::String,
'notificationEnabled' => array(AttributeType::Bool, 'default' => true),
Expand Down
1 change: 1 addition & 0 deletions records/AmForms_FormRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function defineAttributes()
'afterSubmitText' => AttributeType::Mixed,
'submissionEnabled' => array(AttributeType::Bool, 'default' => true),
'displayTabTitles' => array(AttributeType::Bool, 'default' => false),
'redirectUrl' => AttributeType::String,
'sendCopy' => array(AttributeType::Bool, 'default' => false),
'sendCopyTo' => AttributeType::String,
'notificationEnabled' => array(AttributeType::Bool, 'default' => true),
Expand Down
11 changes: 11 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
[
{
"version": "1.4.3",
"downloadUrl": "https://github.com/am-impact/amforms/archive/master.zip",
"date": "2016-05-09T10:00:00+01:00",
"notes": [
"[Added] Added custom redirect URL for forms.",
"[Added] Added a link in the Field Layout Designer, to quickly add a new field.",
"[Fixed] Fixed the way a custom template is being searched for.",
"[Fixed] Fixed sending the form data to a custom submit action."
]
},
{
"version": "1.4.2",
"downloadUrl": "https://github.com/am-impact/amforms/archive/master.zip",
Expand Down
24 changes: 9 additions & 15 deletions services/AmFormsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,18 @@ public function getDisplayTemplateInfo($defaultTemplate, $overrideTemplate)
// Is the override template set?
if ($overrideTemplate) {
// Is the value a folder, or folder with template?
$pathParts = explode(DIRECTORY_SEPARATOR, $overrideTemplate);
$templateFile = craft()->path->getSiteTemplatesPath() . $overrideTemplate;
if (count($pathParts) < 2) {
// Seems we only have a folder that will use the default template name
$templateFile .= DIRECTORY_SEPARATOR . $defaultTemplate;
if (is_dir($templateFile)) {
// Only a folder was given, so still the default template template
$templatePath = $templateFile;
}

// Try to find the template for each available template extension
foreach (craft()->config->get('defaultTemplateExtensions') as $extension) {
if (IOHelper::fileExists($templateFile . '.' . $extension)) {
if (count($pathParts) > 1) {
// We set a specific template
else {
// Try to find the template for each available template extension
foreach (craft()->config->get('defaultTemplateExtensions') as $extension) {
if (IOHelper::fileExists($templateFile . '.' . $extension)) {
$pathParts = explode(DIRECTORY_SEPARATOR, $overrideTemplate);
$defaultTemplate = $pathParts[ (count($pathParts) - 1) ];
$templatePath = craft()->path->getSiteTemplatesPath() . str_replace(DIRECTORY_SEPARATOR . $defaultTemplate, '', implode(DIRECTORY_SEPARATOR, $pathParts));
}
else {
// Only a folder was given, so still the default template template
$templatePath = craft()->path->getSiteTemplatesPath() . $overrideTemplate;
$templatePath = craft()->path->getSiteTemplatesPath() . implode(DIRECTORY_SEPARATOR, array_slice($pathParts, 0, (count($pathParts) - 1)));
}
}
}
Expand Down
35 changes: 17 additions & 18 deletions templates/_display/templates/form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@
{%- set submitValue = (form.submitButton ? form.submitButton : 'Submit'|t) -%}
{%- set submitAction = (form.submitAction ? form.submitAction : 'amForms/submissions/saveSubmission') -%}

<form class="form form--{{ form.handle }}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
{% if form.submitAction -%}
{# Submit form to third party #}
<input type="hidden" name="action" value="{{ submitAction }}">
{% else -%}
{# Submit form to Am Forms #}
<form class="form form--{{ form.handle }}" method="post" accept-charset="utf-8" enctype="multipart/form-data"{% if form.submitAction|length %} action="{{ submitAction }}"{% endif %}>
{# Only CSRF protection, when we stay on this site #}
{% if not form.submitAction|length -%}
{{ getCsrfInput() }}
<input type="hidden" name="action" value="{{ submitAction }}">
<input type="hidden" name="handle" value="{{ form.handle }}">
<input type="hidden" name="namespace" value="{{ namespace }}">
{% if form.redirectEntryId -%}
<input type="hidden" name="redirect" value="{{ form.getRedirectUrl() }}">
{% endif -%}
{% if element.id %}
<input type="hidden" name="submissionId" value="{{ element.id }}">
{% endif %}
{% endif -%}

{%- if antispam -%}
{{ antispam }}
{% endif -%}
<input type="hidden" name="action" value="{{ submitAction }}">
<input type="hidden" name="handle" value="{{ form.handle }}">
<input type="hidden" name="namespace" value="{{ namespace }}">
{% if form.redirectEntryId -%}
<input type="hidden" name="redirect" value="{{ form.getRedirectUrl() }}">
{% elseif form.redirectUrl|length %}
<input type="hidden" name="redirect" value="{{ form.redirectUrl }}">
{% endif -%}
{% if element.id %}
<input type="hidden" name="submissionId" value="{{ element.id }}">
{% endif %}

{%- if antispam -%}
{{ antispam }}
{% endif -%}

{{ body|raw }}
Expand Down
5 changes: 5 additions & 0 deletions templates/forms/_fields/designer.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@


<div id="fieldlayoutform" class="fieldlayoutform">
<div class="buttons secondary-buttons right">
<div class="newwidget btngroup">
<a class="btn submit add icon" href="{{ url('amforms/fields/new') }}" target="_blank">{{ 'New field'|t }}</a>
</div>
</div>

<h2>{{ 'Design your form'|t }}</h2>

Expand Down
9 changes: 9 additions & 0 deletions templates/forms/_fields/form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
errors: form.getErrors('redirectEntryId'),
instructions: 'Where to redirect to upon form submission.'|t
}) }}
{{ forms.textField({
label: 'Custom redirect URL'|t,
id: 'redirectUrl',
name: 'redirectUrl',
value: form.redirectUrl,
errors: form.getErrors('redirectUrl'),
instructions: 'Where to redirect to upon form submission.'|t,
placeholder: 'http://www.domain.com/return-here'
}) }}
<hr>
{{ forms.lightswitchField({
label: 'Save submissions'|t,
Expand Down
1 change: 1 addition & 0 deletions translations/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'Couldn’t save settings.' => 'Kon de instellingen niet opslaan.',
'Couldn’t save submission.' => 'Kon de inzending niet opslaan.',
'Criteria' => 'Criteria',
'Custom redirect URL' => 'Aangepaste redirect URL',
'Custom submit action URL' => 'Aangepaste verzendknop (actie) URL',
'Custom submit button text' => 'Aangepaste verzendknop tekst',
'Custom text after submit' => 'Aangepaste tekst na inzending',
Expand Down

0 comments on commit d3a43da

Please sign in to comment.