If you have html in in a record.body you should display it with
{{=XML(record.body)}}
or better, to avoid XSS Injections
{{=XML(record.body,sanitize=True)}}
You can also specify which tags are allowed and which attributes
{{=XML(record.body,sanitize=True, permittied_tags=
['a'],allowed_attributes={'a':['href']})}}
When creating a record with SQLFORM(db.mock) or editing with SQLFORM
(db.mock,record), the body, by default is rendered by
<textarea name="body" id="mock_body"></textarea>
You can enable nicedit with the followin javascript (assuming you have
nicedit.* files in the static folder):
<script src="/{{=request.application}}/static/nicEdit.js"
type="text/javascript"></script>
<script><!--
$(document).ready(function(){
new nicEditor({fullPanel : true, iconsPath : '/
{{=request.application}}/static/nicEditorIcons.gif'}).panelInstance
('mock_body');
});
//--></script>
Massimo
On Jan 2, 4:10 am, annet <[email protected]> wrote:
> I built a simple mock app to explore nicedit. As a model I defined a
> table:
>
> db.define_table('mock',
> SQLField('body', 'text'),
> migrate='mock.table')
>
> In the view I manage to insert a text into the mock table, and to
> prepopulate the text area with the inserted text, so the user can
> update the text. However when I want to display the text in a view,
> the contents of the field 'body' is displayed the way it is stored in
> the database, the html is not interpreted, the tags are displayed as
> well.
>
> Furthermore, I would like to remove the toolbars from the nicedit
> editor, so that the user can only use the return key to enter a line
> break.
>
> I hope one of you knows how to solve these two problems,
>
> Best regards,
>
> Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---