Welcome Guest, Not a member yet? Register   Sign In
Trying to apply a function to form validation set_value [SOLVED, with thanks!]
#1

[eluser]nuwanda[/eluser]
Upon errors, I'm trying to use set_value like this in my view:

Code:
'value' => set_value((preg_replace ('/\r\n|\r|\n/', ' ','link_description')),'')

The link_description is the text in a textarea. I want to strip the new lines and carriage returns before displaying it.

The form displays the text as inputted but without the newlines stripped. The preg_replace (tested separately) works.

I'm thinking the set_value can't get a handle on text_description and instead defaults to the original text.

How can I apply a function to the set_value?

Edit: btw, I'm using strip_tags in the validation rule, but that ain't removing the newlines.

Edit 3: if I could apply preg_replace to my validation rule, I'd be fine. But I can't as the rules only take php functions that accept one param. You can do it with something like trim.

Edit 2: my goal is to take the textarea input and save it to my db as plain text. That actually works fine, it's just redisplaying it in the form that's the problem.


Messages In This Thread
Trying to apply a function to form validation set_value [SOLVED, with thanks!] - by El Forum - 11-17-2010, 01:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB