Jump to content

Search the Community

Showing results for tags 'Form'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hi all, Currently I am working on a filter for all the products in a category. So I've set up a class and built a (PW) form in it. When the user clicks on continue the form should return a processform function which sets the variable of the form in a session. Later in the file I want to read out that session and use that variable to select which products should show up and which should be hidden. So now with code examples to make it a bit more clear for you: In my file I start with a class: class classname { public function ShowForm() { $form = $this->Form1(); if ($this->input->post->submit) { if ($this->processForm1($form)) $this->session->redirect("./"); } return $form->render(); } Then a form inside the class: protected function Form1() { $form = wire('modules')->get("InputfieldForm"); $form->description = "Fill in the fields to find the mouse which fits your wishes"; $form->label = "Mouse Selector"; $form->action = "./"; $form->method = 'post'; $f = wire('modules')->get("InputfieldRadios"); $f->name = "Hand"; $f->label = "label"; $f->addOption(1, "1"); $f->addOption(2, "2"); $form->add($f); $this->addSubmit($form, 'Continue'); return $form; } This function is called when the user submits: protected function ProcessForm1($form) { $form->processInput($this->input->post); $this->session->hand = (int)$form->get("Hand")->value; } As you see I store the variable of the submitted form in a session. After closing the class I continue with building the page and then I want to read out that variable: $value = $this->session->hand; $content .= "Value of 'Hand': " . $value; But when I execute this on my website I cannot see the value of the form. Have I done something wrong or how can I fix this? Thanks in advance, ~Harmen
  2. what is the most convenient way to create a form? As far as I can see, there are three approaches: - forms using API - module Form Template Processor and Mailer - module FormTemplateProcessor As a newbie, it is not easy to find out all the pros and cons of each approach. What do you suggest?
  3. I need to figure out how to make a simple front end event registration/RSVP; enter full name + email address for the guest list (database), receive an email confirmation. Where to start with this? I know how a regular html form works. What does a basic Processwire form look like?
  4. Hi guys.. I was wondering.. How do I render or output simpel <input> markup?? The list output that InputfieldForm makes is tomutch.. Im loading a template (without file) and I want to output the same fields as a form in the frontend.. Thanks for all your work...
  5. As the title states, I am trying to process a form and save the form's data as a new page. I have looked at Soma's post, but it seems (as least to me), that it tackles submission forms etc. I know what I am trying to do is very very similar. The Form: <form role="form" method="post" action="./" > <div class="form-group"> <label for="code">Enter 4-Digit Code:</label> <input type="code" class="form-control" id="code"> </div> <button type="submit" name="submit" class="btn btn-default">Submit</button> </form> And the processing: if($input->post->submit) { $code = Trim(stripslashes($_POST['code'])); $p = new Page(); $p->setOutputFormatting(false); $p->template = 'singular'; // example template $p->parent = wire('pages')->get('/'); // example parent $p->name = $code; // example name $p->title = "Test Title"; $p->save(); echo "page ID {$p->id} created!<br>"; } else { // output contact form echo "Negative Ghost Rider"; } ?> I have been scratching my head as to why this doesn't seem to work for about an hour. I am sure I must be missing something, or trying to go about this the wrong way. The form seems like it submits, but there is no page added to the backend.
  6. I am trying to apply onkeyup or jquery keyup to a PW form - to autogenerate a username from a real name. This javascript/jquery works fine on test html input fields: But I can't get it to work on the fields generated by the PW forms API, even though the input id names are exactly the same. What am I missing?
  7. Hello, I am using the form API for forms, and I have some defaults that are saved via a cookie. So if someone has visited the site previously, if they return to complete a query form etc, the idea is that these are prepopulated in the form. I am using InputFields and using $fieldname->render() to create the form fields. Can I just set the value of an Input field (after first checking we are not in the middle of a POST)? What I don't get is when Inputfield get populated from POST - it seems to be populated as soon as it gets instanced, because if the form is completed, but has errors, the form field contents get remembered from the POST, even through I haven't done a processInput yet. I am guessing I can't just say $nameformfield->value ? $formfield->value : $_COOKIE['name'];
  8. Hello everyone, I need to rewrite entire application and I want to choose PW for speed reason and logic. I love the roles/permissions system and relationships in db, but now the question.. My app is based on users roles, foreach user role I need to write a big form (around 30fields)->store in database->edit and show the form. Simple crud system in frontend. I can not find a guide to do this, I would use as much as possible the PW's API can you give me some advice? edit: this module works fine! http://modules.processwire.com/modules/form-template-processor/ @ryan with the upload fields the page say "The page must be saved" my code in my template is: $form = $modules->get('FormTemplateProcessor'); $form->template = $templates->get('my_template'); $form->requiredFields = array('field1', 'field2', 'field3'); $form->parent = $page; echo $form->render(); Thank you all guys!
  9. Is there a free way for me to add a contact form in my PW site? As far as I know I should buy the form builder module for that?
  10. I need to create an electronic gateway that will hide a particular file until a user first enters and confirms their country of residence, and I'm not sure where to start. The basic process is – a form is displayed asking for country of residence, a checkbox for terms and conditions, and a submit button. After passing this there is a second screen which reiterates the conditions, possibly with extra information, and a second checkbox/submit button. Passing that will display the file. They's also like to obfuscate the URL or similar, so the screens above can't be bypassed and the file accessed directly. I've been looking through the creating forms with the api thread but it's a very long topic and Ive not been able to get very far with it. I implemented Soma's first bit of code from that thread but it doesn't seem to process the form/pick up any errors, etc. Is this the best route to stick with, or would FormBuilder be a good alternative?
  11. Hello, I am building one form to send email with WireMailSmtp every thing is working fine, only thing attachments are sending with email without any extension. what i want to do is 1. first check the attached file and only allow image/ pdf and word file to be attached 2. send email with attachment. here is my code if (isset($input->post->submit)) { $form = array( 'name' => $input->post->name, 'email' => $input->post->email, 'message' => $input->post->message, 'email2' => $input->post->email2 ); $photo=$filetemp = $_FILES["photo"]; /// how to check that file is only image $resume=$filetemp = $_FILES["resume"]; /// how to check the file is only PDF or word file /// email12 is for spam boot if($form[email2] =="") { $toName='my website'; $toEmail=$page->email; $subject="CV EMail"; $textBody= "Full name: $form[name]\n" . "Email: $form[email]\n" . "Message: $form[message]"; $mail = wireMail(); $mail->to($toEmail, $toName); $mail->from = $toEmail; $mail->subject($subject); $mail->attachment($photo); $mail->attachment($resume); $mail->body($textBody); $numSent = $mail->send(); if($numSent) { $output="Message Send"; }else{ $output="Message Not Send"; } } }
  12. i have problem with send muliple files, for one file it works, for multiple not, what should I do with this code ? <?php if($_POST){ unset($_POST["send"]); //print_r($_POST); unset($_POST["pliki"]); $p = new Page(); $p->template = 'page'; $p->parent = '1043'; $p->user_id = $user['id']; foreach($_POST as $v=>$pr){ if($pr!=''){ $p->{$v} = $pr; } } $p->save(); $pp = $pages->get($p->id); $pp->setOutputFormatting(false); if(isset($_FILES['pliki'])){ $errors= array(); $file_name = $_FILES['pliki']['name']; $file_size =$_FILES['pliki']['size']; $file_tmp =$_FILES['pliki']['tmp_name']; $file_type=$_FILES['pliki']['type']; $file_ext=strtolower(end(explode('.',$_FILES['pliki']['name']))); //$name = strtolower($sanitizer->name($file_name)); //'../../site/assets/files/'.$p->id.'/'.$name) $expensions= array("jpeg","jpg","png","docx","doc","pdf"); if(in_array($file_ext,$expensions)=== true){ move_uploaded_file($file_tmp,"../../site/assets/files/".$pp->id."/".strtolower($sanitizer->name($file_name))); $pp->pliki->add($file_name); } } $pp->save(); } ?> My input looks like this: <input type="file" id="pliki" name="pliki[]" multiple>
  13. Hi all, I need a page for users to post questions to moderators. I'm reusing the Discussions module and the Comment module for the replies (I didn't like the idea of having hundred of pages for replies so I modified it). To handle the form, the Discussions module to autoload in every pages and I think it could pose performance issue. So my question is: Is there anyway for a module to handle a submitted form without setting autoload = true? i.e. processwire loads the module on-demand.
  14. Hi there, I’ve built a form containing a list of products and their price. Some of these products got no exact price, mean it is individual. Ive read the API from InputSelect.module, but I don’t really understand how to add attributes to my options from the selectbox. I am adding products like this: $field->addOption($prod->product_title); Now I want to add also an attribute „disabled“ if there is no value for price. Like: if(!$prod->product_price) { // Code needed } Can somebody help me to solve this? Greetings from Nuremberg.
  15. Hi everyone, I'm having a problem with a form I'm creating using the api. The form consist on multiple text fields, one file, and an Options field, everything works fine, except for the options field. The form creates fine, the main problem is on submit. I'm getting this error: Warning: Invalid argument supplied for foreach() in C:\Local\htdocs\wire\modules\Fieldtype\FieldtypeOptions\FieldtypeOptions.module on line 277 I already tried to check the type and use $post_value->id but it's not working. My code: if($input->post->submit_save) { // user submitted the form, process it and check for errors $form->processInput($input->post); $errors = array(); $required_fields = array(); $fields = array(); $post_value = $input->post->{$f->name}; switch ( $f->type ) { case 'text': $the_value = $sanitizer->text( $post_value ); break; case 'textarea': $the_value = $sanitizer->textarea( $post_value ); break; case 'checkbox': $the_value = isset( $post_value ) ? 1 : 0; break; default: $the_value = $post_value; break; } $fields[$f->name] = $the_value; foreach ( $fields as $key => $value ) { $page->$key = $value; } $page->of(false); $page->save(); } Any Ideas? Thanks
  16. Hello, I am building a frontend form following Soma's great example on a PW 2.7.2 stable install. The pages that I edit with the form already exist. My form includes a single image field, CKEditor fields and some normal text fields. The form renders fine, all CSS and JS is in place. I can even use the pwImage plugin on the CKEditor field and it loads the image from that page. When there already is an image present in the image field and I submit the form, I get this error: Fatal error: Exception: Method Pageimage::path does not exist or is not callable in this context (in /var/www/utgpwnew/wire/core/Wire.php line 358) #0 [internal function]: Wire->___callUnknown('path', Array) #1 /var/www/utgpwnew/wire/core/Wire.php(398): call_user_func_array(Array, Array) #2 /var/www/utgpwnew/wire/core/Wire.php(333): Wire->runHooks('callUnknown', Array) #3 /var/www/utgpwnew/wire/core/Wire.php(337): Wire->__call('callUnknown', Array) #4 /var/www/utgpwnew/wire/core/Wire.php(337): Pageimage->callUnknown('path', Array) #5 /var/www/utgpwnew/wire/modules/Fieldtype/FieldtypeFile.module(119): Wire->__call('path', Array) #6 /var/www/utgpwnew/wire/modules/Fieldtype/FieldtypeFile.module(119): Pageimage->path() #7 /var/www/utgpwnew/wire/core/Wire.php(459): FieldtypeFile->hookProcessInput(Object(HookEvent)) #8 /var/www/utgpwnew/wire/core/Wire.php(333): Wire->runHooks('processInput', Array) #9 /var/www/utgpwnew/wire/core/InputfieldWrapper.php(636): Wire->__call('processInput', Array) #10 /var/www/utgpwnew/wire/core/Inp in /var/www/utgpwnew/index.php on line 248 If the image field is empty, I get this error on submit Fatal error: Call to a member function path() on a non-object in /var/www/utgpwnew/wire/modules/Fieldtype/FieldtypeFile.module on line 119 If I change the image field to hold more than one image, I don't get the error and the form submits fine with and without one or more images in the field From debugging I see that the error is triggered from $form->processInput($this->input->post); So the code does not work on single image fields. Is there a way to fix this? Any help would be much appreciated.
  17. How can I achieve something like this where I can add more Conditions or delete them: Inside this Form where I create Segments for a Mailchimp Account Form processing looks like this: if($this->input->post->createSegment) { $form->segmentnameParam->required = 1; $form->fieldParam->required = 1; $form->operatorParam->required = 1; $form->searchParam->required = 1; $form->match->required = 1; $form->processInput($this->input->post); if(!$form->getErrors()) { $segment_name = $this->sanitizer->text($form->get("segmentnameParam")->value); $field_name = $form->get("fieldParam")->value; $operator = $form->get("operatorParam")->value; $search_value = $this->sanitizer->text($form->get("searchParam")->value); $match = $this->sanitizer->text($form->get("match")->value); $res = $this->mailchimp->call("/lists/segment-add", array( "id" => $list_id, "opts" => array( "type" => "saved", "name" => $segment_name, "segment_opts" => array( "match" => $match, "conditions" => array( array( "field" => $field_name, "op" => "eq", "value" => $search_value, ) ) ) ) )); if($res){ $this->message(sprintf($this->_("Created new Segment called: '%s'"), $segmentnameParam)); } $this->session->redirect("../edit/?id=$list_id"); } }
  18. Hey guys, I'm really really desperate for help at this stage, for my own sanity mostly. I've been trying to set up a form that requires several fields one of which is a file upload, the user can upload max 10 files with extension jpg/png/jpeg and these are sent to the admin email as attachments. Currently this i am using the InputfieldFile module, I have moved it over to /site/modules because hooking the return html wasn't enough for my needs. So basically I have this. $images = $modules->get("InputfieldFileCustom"); $images->attr('label', "Upload your images"); $images->required = 0; $images->maxFiles = 10; $images->attr('id+images','image'); $images->attr('placeholder','no file selected'); $images->attr('extensions','jpg'); $form->append($images); I expected output that would allow me to upload and delete files. Except right now my biggest issue is the fact that the remove button isn't being displayed because the ___renderItem method isn't being run and I have no idea how to make this work. I'm going to have to do a lot of fun stuff with the markup for the majority of the render methods but I can't do anything until I get the remove button to display. I also made a inputfieldfilecustom.js which is imported on the page. I've renamed all instances of InputFieldFile to InputFIeldFileCustom (in both js and module) Begging for help around now. it would be incredibly appreciated if someone can give me any direction.
  19. This has probably been asked a million times, but I can't seem to find an answer. I have always just used a php script to process the emails and was excited that I could pass in an email address from a page to the script using $page. However, this does throw a 403. I was told that I shouldnt be doing it this way, but I was wondering how do you all go about handling emails? I was going to use the same page template, but I need the option of changing out the to email address dynamically.
  20. I have a contact form that feeds to a engine.php. However when I go to fill it out, I get a 403 error )permission denied. I am using mamp, so maybe it is an issue with this. However, I was wondering if anyone else had run into this problem before. I have the url to the .php file using " <?php echo $config->urls->templates?>form/
  21. Hello, I have a form in my html which sends an email with this result. This works perfectly on my html/css... but the moment I use this with processwire I get the following screen with: Forbidden You don't have permission to access /djfemke/_cms_processwire/site/templates/_php/form-to-email.php on this server. So I thought... maybe there are some permissions which I have activated or something like that. This form after goes to a file which manages the form. This is inside my url structure as you can see in the picture. Do you have any idea how to change this to make it work? Under you have the url structure and my code of my form just in case. REALLY THANK YOU : <form name="form1" action="<?php echo $config->urls->templates?>_php/form-to-email.php" method="post"> <div id="form_box" class="gradient"> <div id="center_box"> <h3>WANT TO BOOK ME?</h3> <div id="form_data"> <table> <tr> <td><input type="text" value="Company name" class="gradient" name="company" /></td> <td class="tdright"><input type="text" value="Name" class="gradient" name="name" /></td> </tr> <tr> <td><input type="text" value="Telephone" class="gradient" name="telephone" /></td> <td class="tdright"><input type="text" value="Email" class="gradient" name="email" /></td> </tr> <tr> <td> <input type="text" id="dateField" /> </td> </tr> </table> </div>
  22. Hey all, I'm brand new to processwire and have already fallen in love with it. Currently I'm building my first website with it and I need a way to style the form builder generated forms with CSS. I know it's possible to style them with the jQuery UI themeroller, but I need more direct control. I've looked through all the CSS files I thought could be related with the form, but I can't find how to add my custom styles via CSS. (I can't access the markup directly to do a hackathon because the forms are embedded via iframe.) Thanks in advance, Nick
  23. Hi, I'm about to start developing a website in Processwire but did a bit of research and could'nt find any way to create a form with confirmation message loaded by AJAX when a form is submitted + validated. Is that possible? I think of something similar to Contact Form 7 for WP (when the visitor submits the form it should get validated and if every field validates and email gets sent the visitor gets a message like "Thank you for your message!" without page reload). Is that possible to do this in Processwire or anything thats on the Feature list? From what i can understand theres three modules (Form builder, Form Template Processor and Mailer and Simple Contact Form) that can create forms and also a API-function to call and create the form manually. Is there any of the above which supports ajax submit with "Thank you"-message on the same page without reloading the page on submit? Seems pretty basic, but maybe i've missed something. Thank you!
  24. I have the following sidebar.inc included on my Shop page which is the main index of items: <?php foreach($input->get as $key => $val) { echo htmlentities("$key = $val") . "<br>"; } $selector = ''; $summary = array( "categories" => "", "agegroups" => "", "keywords" => "", ); if($input->get->categories) {} $sidebar = "<form id='search_form' method='get' action='{$config->urls->root}shop/'><div class='row'>"; $taxonomies = $pages->find("template=product_taxonomies"); foreach($taxonomies as $t) { $items = $t->children; $sidebar .= "<div class='small-6 large-12 columns'><h3>{$t->title}</h3>"; foreach($items as $i) { $sidebar .= "<input id='$i->name' name='$t->name' value='$i->name' type='checkbox'><label for='$i->name'>$i->title</label><br>"; } $sidebar .= "</div>"; } $sidebar .= "<input id='search_keyword' name='keyword' type='text'/>"; $sidebar .= "<div class='large-12 columns'><input type='submit' id='search_submit' name='submit' value='Search'></div></div></form>"; Checking more than one input of the same name only produces the last value of those. Can anyone advise me on how to make these multi-select filters return multiple values?
  25. Hello, from the day i am using PW every day i am loving it more and more, its really great. i am trying to create a page for website where people can apply for job and send CV as attachment too. i was searching forums from last few days and create one page with combinations of many posts in form, my code is bellow. <style> #email2 { display:none; } #message-error { color:#F00;} #message-success { color:#09F;} </style> <?php // check if the form was submitted $spam_check=trim($input->post->email2); if($input->post->submit && $spam_check == '') { $sent = false; $error = ""; $emailTo = $page->email; // sanitize form values or create empty $form = array( 'fullname' => $sanitizer->text($input->post->fullname), 'job_title' => $sanitizer->text($input->post->job_title), 'job_id' => $sanitizer->text($input->post->job_id), 'contact' => $sanitizer->text($input->post->contact), 'email' => $sanitizer->email($input->post->email), 'comments' => $sanitizer->textarea($input->post->comments), ); $msg = "Full Name: $form[fullname]\n" . "Contact number: $form[contact]\n" . "Job Title: $form[job_title]\n" . "Job Id: $form[job_id]\n" . "Email: $form[email]\n" . "Comments: $form[comments]"; // attachment if(isset($_POST['submit']) && !empty($_FILES['file']['size'])) { $filename = $_FILES["file"]["name"]; $filetype = $_FILES["file"]["type"]; $filesize = $_FILES["file"]["size"]; $filetemp = $_FILES["file"]["tmp_name"]; if($filesize < 10) throw new Exception("File too small"); if($filesize > 1000000) throw new Exception("File too big"); $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if(!in_array($ext, array('doc', 'pdf', 'docx'))) throw new Exception("Invalid file type"); $destination = $config->paths->cache . $user->name . '.' . $ext; if(!move_uploaded_file($filetemp, $destination)) throw new Exception("Unable to move uploaded file"); $fp = fopen($destination, "rb"); $file = fread($fp, $filesize); $file = chunk_split(base64_encode($file)); unlink($destination); } // This two steps to help avoid spam $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$filetype." "; $headers .= "name=\"".$filename."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$filename."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; if(mail($emailTo, "Job Application", $msg, "From: $form[email]",$headers)) { // populate body with success message, or pull it from another PW field $messageok = "<div id='message-success'><p>Thanks, your message has been sent.<b>We will Contact you back</p> </div>"; $sent = true; }else{ $error= "<div id='message-error'><p>Error! Mail Not Sent.</p></div>"; $sent = false; } } include("./head.inc"); ?> here is my form code Please enter your contact details below.<br /><br /> <?php if(strlen($error)>1) { echo $error; } // to get JOB title and id $job=$pages->get($input->urlSegment1); if(!$sent) { ?> <form action="./" method="post" class="contact-form" id="contactform"> <input id="job_title" name="job_title" type="hidden" value="<?php echo $job->title;?>" /> <input id="job_id" name="job_id" type="hidden" value="<?php echo $job->job_id;?>" /> <input Placeholder="Please Enter Your Name" name="fullname" id="fullname" value="<?php echo $form[fullname];?>" /> <input type="text" Placeholder="Please Enter Your Contact Number" name="contact" id="contact" value="<?php echo $form[contact];?>" /> <input type="text" name="email" id="email" Placeholder="Please Enter Your Email" /> <input type="file" name="file" id="file" value="Uplode Cv" /> <textarea id="comments" name="comments" cols="60" rows="3" Placeholder="Please Enter Your Message"><?php echo $form[comments];?> <input type="text" name="email2" id="email2"> <input name="submit" id="submit" type="submit" value="Send" /> </form> <?php }else{ echo $messageok; } include("./foot.inc"); ?> form is displaying properly but emails are not going and i am getting error "Error! Mail Not Sent." what i want to do is send email with attachment and then delete uploaded file from server and of course secure. really appreciate your update. Thanks
×
×
  • Create New...