Skip to content
Snippets Groups Projects
Commit 15827077 authored by lobo's avatar lobo
Browse files

Merge pull request #888 from cividesk/CRM-12716

CRM-12716 - Limit the number of chars that can be entered in Notes custom fields
parents ace01fda 2f940a36
No related branches found
No related tags found
No related merge requests found
......@@ -762,13 +762,15 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
else {
$attributes .= 'rows=4';
}
if ($field->note_columns) {
$attributes .= ' cols=' . $field->note_columns;
}
else {
$attributes .= ' cols=60';
}
if ($field->text_length) {
$attributes .= ' maxlength=' . $field->text_length;
}
$element = &$qf->add(strtolower($field->html_type),
$elementName,
$label,
......@@ -958,7 +960,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
break;
case 'RichTextEditor':
$qf->addWysiwyg($elementName, $label, array('rows' => $field->note_rows, 'cols' => $field->note_columns), $search);
$attributes = array('rows' => $field->note_rows, 'cols' => $field->note_columns);
if ($field->text_length) {
$attributes['maxlength'] = $field->text_length;
}
$qf->addWysiwyg($elementName, $label, $attributes, $search);
break;
case 'Autocomplete-Select':
......
......@@ -123,6 +123,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
if ($this->_id) {
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $this->_values);
// note_length is an alias for the text_length field
$this->_values['note_length'] = CRM_Utils_Array::value('text_length', $this->_values);
}
if (self::$_dataToLabels == NULL) {
......@@ -445,9 +447,16 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
$attributes['note_rows'],
FALSE
);
$this->add('text',
'note_length',
ts('Maximum length') . ' ',
$attributes['text_length'], // note_length is an alias for the text-length field
FALSE
);
$this->addRule('note_columns', ts('Value should be a positive number'), 'positiveInteger');
$this->addRule('note_rows', ts('Value should be a positive number'), 'positiveInteger');
$this->addRule('note_length', ts('Value should be a positive number'), 'positiveInteger');
// weight
$this->add('text', 'weight', ts('Order'),
......@@ -956,6 +965,12 @@ SELECT id
}
}
// The text_length attribute for Memo fields is in a different input as there
// are different label, help text and default value than for other type fields
if ($params['data_type'] == "Memo") {
$params['text_length'] = $params['note_length'];
}
// need the FKEY - custom group id
$params['custom_group_id'] = $this->_gid;
......
......@@ -29,4 +29,6 @@ SELECT @bounceTypeID := max(id) FROM civicrm_mailing_bounce_type WHERE name = 'S
INSERT INTO civicrm_mailing_bounce_pattern (bounce_type_id, pattern)
VALUES (@bounceTypeID, 'X-HmXmrOriginalRecipient');
-- CRM-12716
UPDATE civicrm_custom_field SET text_length = NULL WHERE html_type = 'TextArea' AND text_length = 255;
......@@ -115,9 +115,11 @@ function custom_option_html_type( ) {
if ( data_type_id == 4 ) {
cj("#noteColumns").show();
cj("#noteRows").show();
cj("#noteLength").show();
} else {
cj("#noteColumns").hide();
cj("#noteRows").hide();
cj("#noteLength").hide();
}
if ( data_type_id > 3) {
......@@ -209,6 +211,10 @@ function custom_option_html_type( ) {
<td class="label">{$form.note_columns.label}</td>
<td class="html-adjust">{$form.note_columns.html}</td>
</tr>
<tr class="crm-custom-field-form-block-note_length" id="noteLength" {if $action neq 2 && ($form.data_type.value.0.0 != 4)}class="hide-block"{/if}>
<td class="label">{$form.note_length.label}</td>
<td class="html-adjust">{$form.note_length.html} <span class="description">{ts}Leave blank for unlimited. This limit is not implemented by all browsers and rich text editors.{/ts}</span></td>
</tr>
<tr class="crm-custom-field-form-block-weight" >
<td class="label">{$form.weight.label}</td>
<td>{$form.weight.html|crmAddClass:two}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment