mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge branch '4.5' into 4
This commit is contained in:
commit
77538fac0b
@ -61,7 +61,10 @@ class EditableTextField extends EditableFormField
|
|||||||
|
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$this->beforeUpdateCMSFields(function ($fields) {
|
// PHP 5.3 compat
|
||||||
|
$self = $this;
|
||||||
|
|
||||||
|
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Main',
|
'Root.Main',
|
||||||
NumericField::create(
|
NumericField::create(
|
||||||
@ -78,7 +81,7 @@ class EditableTextField extends EditableFormField
|
|||||||
DropdownField::create(
|
DropdownField::create(
|
||||||
'Autocomplete',
|
'Autocomplete',
|
||||||
_t('EditableTextField.AUTOCOMPLETE', 'Autocomplete'),
|
_t('EditableTextField.AUTOCOMPLETE', 'Autocomplete'),
|
||||||
$this->config()->get('autocomplete_options')
|
$self->config()->get('autocomplete_options')
|
||||||
)->setDescription(_t(
|
)->setDescription(_t(
|
||||||
'EditableTextField.AUTOCOMPLETE_DESCRIPTION',
|
'EditableTextField.AUTOCOMPLETE_DESCRIPTION',
|
||||||
'Supported browsers will attempt to populate this field automatically with the users information, use to set the value populated'
|
'Supported browsers will attempt to populate this field automatically with the users information, use to set the value populated'
|
||||||
|
@ -2,35 +2,32 @@
|
|||||||
* Email recipient behaviour.
|
* Email recipient behaviour.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function ($) {
|
(function($) {
|
||||||
$(document).ready(function () {
|
$.entwine('ss', function($) {
|
||||||
|
|
||||||
var sendPlain = $('input[name="SendPlain"]');
|
|
||||||
var recipient = {
|
var recipient = {
|
||||||
// Some fields are only visible when HTML email are being sent.
|
// Some fields are only visible when HTML email are being sent.
|
||||||
updateFormatSpecificFields: function () {
|
updateFormatSpecificFields: function () {
|
||||||
var sendPlainChecked = sendPlain.is(':checked');
|
var sendPlainChecked = $('input[name="SendPlain"]').is(':checked');
|
||||||
|
|
||||||
$(".field.toggle-html-only")[sendPlainChecked ? 'hide' : 'show']();
|
$('.field.toggle-html-only')[sendPlainChecked ? 'hide' : 'show']();
|
||||||
$(".field.toggle-plain-only")[sendPlainChecked ? 'show' : 'hide']();
|
$('.field.toggle-plain-only')[sendPlainChecked ? 'show' : 'hide']();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$.entwine('udf.recipient', function ($) {
|
$('#Form_ItemEditForm .EmailRecipientForm').entwine({
|
||||||
$('#Form_ItemEditForm').entwine({
|
|
||||||
onmatch: function () {
|
onmatch: function () {
|
||||||
recipient.updateFormatSpecificFields();
|
recipient.updateFormatSpecificFields();
|
||||||
},
|
},
|
||||||
|
|
||||||
onunmatch: function () {
|
onunmatch: function () {
|
||||||
this._super();
|
this._super();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sendPlain.entwine({
|
$('#Form_ItemEditForm .EmailRecipientForm input[name="SendPlain"]').entwine({
|
||||||
onchange: function () {
|
onchange: function () {
|
||||||
recipient.updateFormatSpecificFields();
|
recipient.updateFormatSpecificFields();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
17
tests/Model/EditableFormField/EditableTextFieldTest.php
Normal file
17
tests/Model/EditableFormField/EditableTextFieldTest.php
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user