phippu Posted June 27, 2016 Share Posted June 27, 2016 Hello everyone! I'm stumbling upon a form, again... I'm trying to get the Text out of my Form with the newline characters. I'm using PW 2.5.3 What I have in Code a little bit cut down: $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'subscribe-form'); // create a textarea input for the actual message $field = $modules->get("InputfieldTextarea"); $field->label = "Nachricht"; $field->attr('id+name','message'); $field->required = 1; $form->append($field); // append the field to the form // form was submitted so we process the form if($input->post->submit) { $message = $sanitizer->textarea($form->get("message")->value); $out .= "<strong>Nachricht:</strong></br>"; $out .= $message."</p>"; } else { // render out form without processing $out .= $form->render(); } I can't get it with newlines, what am I doing wrong? Thanks in advance for your support Link to comment Share on other sites More sharing options...
kixe Posted June 28, 2016 Share Posted June 28, 2016 Sanitizer removes linefeeds. Allow multiline in the options array. This one should work: $message = $sanitizer->textarea($form->get("message")->value, array('multiLine' => true)); // or $message = $sanitizer->textarea($input->post->message, array('multiLine' => true)); Link to comment Share on other sites More sharing options...
flydev Posted June 28, 2016 Share Posted June 28, 2016 I just tested it by curiosity and can't get output multiline... I think we are missing something simple. Link to comment Share on other sites More sharing options...
phippu Posted June 28, 2016 Author Share Posted June 28, 2016 Sorry I forgot an important detail, it was a little bit late yesterday @kixe I tried this "multiline" option. Unfortunately it doesn't work. I also tried the following code: $message = $form->get("message")->value; $message does not contain newline characters, so I suspect to set an option in this code: $field = $modules->get("InputfieldTextarea"); $field->label = "Nachricht"; $field->attr('id+name','message'); $field->required = 1; $form->append($field); // append the field to the form Link to comment Share on other sites More sharing options...
flydev Posted June 28, 2016 Share Posted June 28, 2016 (edited) The simple thing we was missing (if not another) is nl2br() - @phippu try : $out .= nl2br($message); You should get your multiline output. Edited June 28, 2016 by flydev link reference Link to comment Share on other sites More sharing options...
phippu Posted June 28, 2016 Author Share Posted June 28, 2016 Thank you very much! That's very logic, but wasn't aware of this behavior... It's now working! shouldn't this php method be implemented in Textarea? Just a thought... Link to comment Share on other sites More sharing options...
LostKobrakai Posted June 28, 2016 Share Posted June 28, 2016 Newline characters are the de facto correct way of handling newlines in text. It's just that html does not care about them, which is why you need <br> tags instead. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now