From: Nicolas Ganivet Date: Wed, 29 May 2013 08:00:04 +0000 (-0600) Subject: Complete implementation, including database upgrade. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2f940a36bedc9aea34b186bde47f567c13b8160e;p=civicrm-core.git Complete implementation, including database upgrade. --- diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 0827142dd8..eae36c04d0 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -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': diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 567eafc4f7..b61baf4e05 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -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; diff --git a/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl index d7d091f711..5f7ad377cc 100644 --- a/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl @@ -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; diff --git a/templates/CRM/Custom/Form/Field.tpl b/templates/CRM/Custom/Form/Field.tpl index c9f0e4e1ce..61c196cfeb 100644 --- a/templates/CRM/Custom/Form/Field.tpl +++ b/templates/CRM/Custom/Form/Field.tpl @@ -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( ) { {$form.note_columns.label} {$form.note_columns.html} + + {$form.note_length.label} + {$form.note_length.html} {ts}Leave blank for unlimited. This limit is not implemented by all browsers and rich text editors.{/ts} + {$form.weight.label} {$form.weight.html|crmAddClass:two}