Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi, it's been a while since I posted - still using Couch, but I'm doing less web work these days, and I guess I usually know what I'm doing now (in my comfort zone anyway)!
My question is this - is there a way to enable Trust Mode on all databound inputs by default? I don't really want to start messing with the couch code, but if you could point me to where and how I could change it, that would be very helpful!
Basically I have a closed system, where logged in (and trusted) users are creating and saving poster templates. I've built it wrong :( - I didn't realise I would need to include some basic HTML tags in the poster fields (mainly line breaks, but potentially em, bold), and I have built the ajax using dbpersist without forms (which means I can't use trust mode I think). Couch is automatically stripping out all the HTML tags...
If I can override the trust mode setting it would save me going back to rebuild it using forms.
Thanks, (and I hope that all made sense)
ewanmc
Hi,

Could you please post some samples of the code you are using for the forms?
Hi KK,
I'll add some code, but the problem is that I didn't use databound forms properly - I'm thinking I'll just have to go back and make some adjustments.
Basically the user edits the text in the poster (javascript updates the text1 field), and I'm submitting the text1 input value using ajax to create a new cloned page. (ignore any basic code errors - this is stripped back from much larger code and I probably broke some stuff)

Code: Select all
<textarea id="text1"><cms:show text_field_hold_1/></textarea>var itemtext1=$('#text1').val(); 
$.ajax({method: "POST",
                    url: "<cms:show k_site_link />additem.php",
                    data: { it_text1: itemtext1  }

They click a button to save the item, and the data is posted using Ajax:
Code: Select all
<cms:set itemtext1 = "<cms:gpc 'it_text1' />" scope="global"/> 
<cms:db_persist
    _masterpage='xxx.php'
    _mode='create'
    _invalidate_cache='0'
    _auto_title='1'
    text_field_1="<cms:show itemtext1/>"

The problem is that any HTML tags are getting stripped out - mainly line breaks, but I've also tried an inline editor for bold and italic. The solution is probably to make the fields an actual databound form, set trust mode to 1, and do it that way. But I would need to restructure the page... So I thought I would be lazy, and ask you if there was a way to enable/disable trust mode altogether, as it's not an issue with the app I'm building.
Thank you!
Hey, just to say that I decided to rebuild it using proper databound forms and trust mode. It would still be nice to know if there is n easy way to make trust_mode default, but I've got everything working.
Thanks for helping KK!
ewanmc
4 posts Page 1 of 1