Tyssen Posted January 17, 2013 Share Posted January 17, 2013 I've used the Form Template Processor module to create a simple contact form but I have a requirement that placeholders be added to all the inputs and textareas. I can do that for the inputs because they have a field in the admin to do that, but textareas don't. This is my first site (and first day) using Processwire so I could be missing something obvious, but does anyone have an idea about how I'd achieve this? Link to comment Share on other sites More sharing options...
Natetronn Posted January 17, 2013 Share Posted January 17, 2013 Hey Tyssen! I updated the module for you though, not sure how to hand it over other than via a gist: https://gist.github.com/4554543 The file I updated was in wire > modules > Inputfield > InputfieldTextarea.module Note: I know how to make a pull requests though, not sure which branch to use (Ryan?) plus, I'm just getting use to looking at PW code so maybe it should be looked over by a PW professional first Also note: I wonder where this should go for the time being. For example I wonder if this will work in the site/module directory since it's now custom. An update to PW of course would overwrite the changes made in the wire/modules/Inputfield version. Anyone care to explain the proper way to handle custom or modified core modules please? Link to comment Share on other sites More sharing options...
Soma Posted January 17, 2013 Share Posted January 17, 2013 Natetronn, that link doesn't work. BTW. Looking at the textarea, there's already a placeholder text you can enter. Maybe you need to update to latest dev version. Link to comment Share on other sites More sharing options...
Tyssen Posted January 17, 2013 Author Share Posted January 17, 2013 @Soma, I'll check out the dev branch, but before I do, after posting I was thinking about it a bit more, and what would be more useful would to be able to control the markup of form output which doesn't seem possible when using the Form Template Processor module, or am I missing something? @Natetronn, you're everywhere. Link to comment Share on other sites More sharing options...
Marty Walker Posted January 17, 2013 Share Posted January 17, 2013 Hi John, This is a basic contact form that I've used in the past. I might help. Cheers Marty <?php /** * basic-form.php - Example of a simple contact form in ProcessWire * */ // set this to the email address you want to send to (or pull from a PW field) $emailTo = 'email@site.com'; // or if not set, we'll just email the default superuser if(empty($emailTo)) $emailTo = $users->get($config->superUserPageID)->email; // set and sanitize our form field values $form = array( 'fullname' => $sanitizer->text($input->post->fullname), 'email' => $sanitizer->email($input->post->email), 'comments' => $sanitizer->textarea($input->post->comments), ); // initialize runtime vars $sent = false; $error = ''; // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($form as $key => $value) { if(empty($value)) $error = "<p class='form-error'>Please completed all fields.</p>"; } // if no errors, email the form results if(!$error) { $subject = "Message from your website contact form"; $message = ''; foreach($form as $key => $value) $message .= "$key: $value\n"; mail($emailTo, $subject, $message, "From: $form[email]"); $sent = true; } } if($sent) { echo "<p>Thank you, your message has been sent.</p>"; // or pull from a PW field } else { // encode values for placement in markup foreach($form as $key => $value) { $form[$key] = htmlentities($value, ENT_QUOTES, "UTF-8"); } // output the form echo <<< _OUT $error <form action="./" method="post"> <label for="fullname">Your name*</label> <input type="text" id="fullname" name="fullname" size="60" value="$form[fullname]" /> <label for="email">Your email*</label> <input type="email" name="email" id="email" size="60" value="$form[email]" /> <label for="comments">Message*</label> <textarea id="comments" name="comments" rows="5" cols="43">$form[comments]</textarea> <input type="submit" name="submit" value="Submit" /> <p class="form-required">* required fields</p> </form> _OUT; } ?> Link to comment Share on other sites More sharing options...
Soma Posted January 17, 2013 Share Posted January 17, 2013 Maybe I also point out this thread. http://processwire.com/talk/topic/2089-create-simple-forms-using-api/ And yes you can change markup and classes to some extend as seen in this thread. Link to comment Share on other sites More sharing options...
Tyssen Posted January 17, 2013 Author Share Posted January 17, 2013 Thanks guys, I'll take a look at both of those. Link to comment Share on other sites More sharing options...
Natetronn Posted January 17, 2013 Share Posted January 17, 2013 Natetronn, that link doesn't work. My mistake, it was late, it works now Link to comment Share on other sites More sharing options...
Tyssen Posted January 17, 2013 Author Share Posted January 17, 2013 Thanks Nate. 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