APICHANGE: added getFormattedValue() for UDF submitted form fields to allow subclasses to overload the stored content. BUGFIX: convert newlines from text submissions to br tags so textarea fields actually come out semi readable

This commit is contained in:
Will Rossiter 2010-05-16 03:55:03 +00:00
parent 3257590dc8
commit fd0fe1b01d
4 changed files with 15 additions and 5 deletions

View File

@ -16,10 +16,10 @@ class SubmittedFileField extends SubmittedFormField {
*
* @return String
*/
function getValue() {
function getFormattedValue() {
return '<a href="'.$this->getLink().'">'. _t('SubmittedFileField.DOWNLOADFILE', 'Download File') .'</a>';
}
/**
* Return the Link object for this field
*

View File

@ -16,5 +16,15 @@ class SubmittedFormField extends DataObject {
static $has_one = array(
"Parent" => "SubmittedForm"
);
/**
* Generate a formatted value for the reports and email notifications.
* Converts new lines (which are stored in the database text field) as
* <brs> so they will output as newlines in the reports
*
* @return String
*/
function getFormattedValue() {
return nl2br($this->dbObject('Value')->RAW());
}
}

View File

@ -15,7 +15,7 @@
<% control FieldValues %>
<tr>
<td class="field">$Title</td>
<td class="value">$Value.RAW</td>
<td class="value">$FormattedValue</td>
</tr>
<% end_control %>
</table>

View File

@ -6,7 +6,7 @@ $Body
<dl>
<% control Fields %>
<dt><strong><% if Title %>$Title<% else %>$Name<% end_if %></strong></dt>
<dd style="margin: 4px 0 14px 0">$Value.RAW</dd>
<dd style="margin: 4px 0 14px 0">$FormattedValue</dd>
<% end_control %>
</dl>
<% end_if %>