Skip to content

Commit

Permalink
Merge branch '4.4' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Aug 21, 2017
2 parents d953603 + c5d8bcf commit a0aa714
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 29 deletions.
7 changes: 5 additions & 2 deletions code/model/editableformfields/EditableTextField.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class EditableTextField extends EditableFormField

public function getCMSFields()
{
$this->beforeUpdateCMSFields(function ($fields) {
// PHP 5.3 compat
$self = $this;

$this->beforeUpdateCMSFields(function ($fields) use ($self) {
$fields->addFieldToTab(
'Root.Main',
NumericField::create(
Expand All @@ -78,7 +81,7 @@ public function getCMSFields()
DropdownField::create(
'Autocomplete',
_t('EditableTextField.AUTOCOMPLETE', 'Autocomplete'),
$this->config()->get('autocomplete_options')
$self->config()->get('autocomplete_options')
)->setDescription(_t(
'EditableTextField.AUTOCOMPLETE_DESCRIPTION',
'Supported browsers will attempt to populate this field automatically with the users information, use to set the value populated'
Expand Down
51 changes: 24 additions & 27 deletions javascript/Recipient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,32 @@
* Email recipient behaviour.
*/

(function ($) {
$(document).ready(function () {
(function($) {
$.entwine('ss', function($) {
var recipient = {
// Some fields are only visible when HTML email are being sent.
updateFormatSpecificFields: function () {
var sendPlainChecked = $('input[name="SendPlain"]').is(':checked');

var sendPlain = $('input[name="SendPlain"]');
var recipient = {
// Some fields are only visible when HTML email are being sent.
updateFormatSpecificFields: function () {
var sendPlainChecked = sendPlain.is(':checked');
$('.field.toggle-html-only')[sendPlainChecked ? 'hide' : 'show']();
$('.field.toggle-plain-only')[sendPlainChecked ? 'show' : 'hide']();
}
};

$(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show']();
$(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide']();
}
};
$('#Form_ItemEditForm .EmailRecipientForm').entwine({
onmatch: function () {
recipient.updateFormatSpecificFields();
},

$.entwine('udf.recipient', function ($) {
$('#Form_ItemEditForm').entwine({
onmatch: function () {
recipient.updateFormatSpecificFields();
},
onunmatch: function () {
this._super();
}
});
onunmatch: function () {
this._super();
}
});

sendPlain.entwine({
onchange: function () {
recipient.updateFormatSpecificFields();
}
});
});
});
$('#Form_ItemEditForm .EmailRecipientForm input[name="SendPlain"]').entwine({
onchange: function () {
recipient.updateFormatSpecificFields();
}
});
});
}(jQuery));
17 changes: 17 additions & 0 deletions tests/Model/EditableFormField/EditableTextFieldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

class EditableTextFieldTest extends SapphireTest
{
public function testGetCmsFields()
{
Config::inst()->remove('EditableTextField', 'autocomplete_options');
Config::inst()->update('EditableTextField', 'autocomplete_options', array('foo' => 'foo'));

$field = new EditableTextField;
$result = $field->getCMSFields();

$autocompleteField = $result->fieldByName('Root.Main.Autocomplete');
$this->assertInstanceOf('DropdownField', $autocompleteField);
$this->assertEquals(array('foo' => 'foo'), $autocompleteField->getSource());
}
}

0 comments on commit a0aa714

Please sign in to comment.