Jump to content

Search the Community

Showing results for tags 'forms'.

  • 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, is there actually a function in Processwire to create forms from a JSON array with corresponding attributes, so that something like { "title":"Duck Count", "type": "InputfieldInteger", "label": "How many ducks?" },{ etc ... } would become a form with all the fields? Otherwise it would be a nice-to-have I guess? I will give it a try for a module now - could be enhanced then. Or has anyone already build something like that? cheers, Steffen
  2. Is there a method to add markup to a single input field when building a form? At present I'd customise the forms markup: $form = $modules->get("InputfieldForm"); $form->setMarkup([ 'item_content' => "{out}<span class='custom-span'></span>", .... ]); Which works but adds the custom span to every inputFieldWrapper. Adjusting setMarkup on an individual field, i.e. $field = $modules->get("InputfieldText"); $field->setMarkup([ 'item_content' => "{out}<span class='different-span'></span>" ]); Calls the same method, setting $markup within inputFieldWrapper.php and adjusting the output of every inputFieldWrapper Therefore I was hoping for a way of appending to the inputfield or wrapper without it being global
  3. Hey all, I have just created a contact form with the PW api (nice and easy as expected, though I found it has some limitations concerning fieldsets and multi-row layout... I know this is a tricky subject, so no offense meant). I'm wondering what would be the best way to prevent the (accidental) resubmission of a form. I usually do this with a redirect after submit and a flash error/success message... is there any PW-ish way to achieve this (e.g., does PW support flash messages, or is this procedure even already implemented in the api somewhere)?
  4. Hello Experts, I am trying to make a quiz contest in processwire. This quiz needs to show one question per page. The aim of this quiz is to get more page views. so I created a template, where Quiz questions can be uploaded. After answering one question the user is redirected to the next question or URL on clicking the submit button. I am unable to get the form data. I have the form template and the final page to evaluate the scores. I dont understand where I am going wrong. Here is my code. Please help me out..... quiz.php <?php include("./head.inc"); include("./functions.php"); ?> <div id="content" class="row inside search-page"> <!-- content starts --> <div class="content-border"> <!-- content-border starts --> <div id="body" class="large-8 columns" role="content"> <!-- body starts --> <div class="large-12 columns"> <form id="form1" name="form1" method="post" action="../process-quiz" > <?php $name = 0; $arrlength1 = count($name); echo $arrlength1; for($x=0;$x<$arrlength1;$x++) { echo "<input type='hidden' name='answer[]' value='$name[$x]' />" ; } $p = $page->question; echo "<h1>Q:<span>{$p}</span></h1>"; if($page->quiz_images !=null) { $image = $page->quiz_images->url; echo "<img src='{$image}'>"; } foreach($page->quiz_options as $c) { echo "<input type='radio' name='answer[]' value=\"{$c->quiz_answer_text}\">{$c->quiz_answer_text}<br/>"; } ?> <input type="submit" name="button" id="button" value="Next" /> </form> </div> </div><!-- body ends --> <?php //include("./sidebar.inc"); ?> </div><!-- content-border ends --> </div><!-- content ends --> <?php include("./footer.inc"); ?> process-quiz.php <?php $name = $input->post['answer']; $arrlength=count($name); $myarray = array(); array_push($myarray, $name); $answers =array('one','right'); $score=0; foreach ($myarray as $innerArray) { // Check type if (is_array($innerArray)){ // Scan through inner loop foreach ($innerArray as $value) { //echo $value."<br />"; foreach($answers as $key) { if($value == $key) { $score++; } } } } } $url = "question-".$arrlength; if($arrlength>2) { $url="process-quiz.php"; } $session->redirect("http://www.example.in/temp/quiz-section/$url",false); echo "<h1>you have scored :".$score."</h1>"; echo '<pre>'; // just to check the user inputs. print_r($myarray); echo '</pre>'; }?>
  5. TL;DR : I'm looking to create dynamic forms which will take fields list from given template & create/save pages dynamically. Hello, I've been using PW for a while for creating web applications like ERP systems and similar applications which have tons of forms. So far I've been creating, processing & validating them manually. While researching I found this link which I found to be very helpful. Code given in that example allows user to create a form based on the fields of any page and save it, which is very cool. Based on that code I tried doing something like this: $p = new Page(); $p->template = "mytemplate"; //I've added few fields to this template $p->parent = "/someparent/"; $p->of(false); // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; // add the page's fields to the form $form->add($p->getInputfields()); // add a submit button to the form $submit = $modules->get('InputfieldSubmit'); $sumit->name = 'submit'; $form->add($submit); // process the form if it was submitted if($input->post->submit){ $form->processInput($input->post); $p->name = date(dmYhisn); $p->save(); } It did create a page but without any data. I know this could be a very stupid thing to try, but I guess it was worth it. More research taught me that probably using ProcessPageAdd module I can create new pages. But I don't know how exactly that works. I'm looking for some guidance about modules & their use on fron-end. Thanks.
  6. A company approached me wanting to convert their paper-based ways of collecting customer information into electronic. Reason being they want to instead use a tablet (in office) and have them fill out everything electronically in order to prevent readability / processing errors and also offer the ability to fill out on their website. The type of information such a company needs from their client is pretty intense and detailed. Customers are filling out multiple documents disclosing personal information, not only about themselves, but also about the defendant - everything from vehicle registration, address / work history to personal identity to the fullest extent) - things like social security numbers, etc. It seems there isn't a sensitive data question not being asked. Not only that but they are also disclosing credit card info (for payment). It's pretty monumental in terms of data. I never accepted the project and said I'll look into what's possible but out of curiosity and being the curious type I am, I have already built a mobile-responsive / electronic version of their entire 200+ question form(s), complete with task completion status, page summary, auto-complete, validation, terms of service. It's damn beautiful but that was the easy. Even though I like getting my feet wet, I am wondering if I should continue or if it's even worth the headaches, not to mention the technical hurdles. The questions I am wondering are numerous (and for understandable reasons). I guess the top would be: I know all this data has to be encrypted and secured to the highest extent. I don't know what's involved or how deep it can get. I do know the risks and the laws governing storage of such sensitive data and also the penalties for the company if it gets stolen. So I'm hesitant to even take on this task for that reason alone; especially since I'm still very much a PHP / programming beginner (although devoted). I don't want to major f*** up I was thinking storage would be on the web host instead of some sort of in-office database? An online back-end would have to be created to retrieve information so that the company then could process it (they wanted it as a pdf). They need some way to retrieve the data. They need to be able to charge / have access to the credit card again at a later date so integration with a payment processor needs to be implemented, correct? I am asking more what direction / route / study material I should look into (first steps) more than specific procedures because I understand it's very involved. If I can't tackle this now, I would like to learn so I can accomplish this in the future because building, integrating and deploying things of this nature is where I would like to go. Just curious on your thoughts. Thanks everyone
  7. As part of the Agile user story system that I'm in the process of building, each story has a list of acceptance tests that go with it. I have this list put together with a repeater, and I've added a checkbox to each test so that developers can mark it off as complete. What I really want to do, however, is not require developers to edit the page to check things off. They aren't writing the stories, only reading them, so I really want to find a way to give them a checkbox on the rendered page itself that can update the state of the checkbox field when they click it. The users viewing the page are already logged in (I'm using Adrian's Protected Mode module to lock down the whole site), so It seems like then first step will be to find the right Process API call to save a change to the page. The second step is probably harder, though, making all this happen from Javascript.
  8. Hi everybody, As much as we hate the CAPTCHA, it is still used. I decided to share my solution of using ProcessWire forms with CAPTCHA. My goals were quite simple: 1. Create a form and customize it. 2. Get an Inputfield for a page field and append this Inputfield to the form. 3. Display a CAPTCHA. 4. Process the form and check its fields for correctness. 5. Check the CAPTCHA. 6. If steps 4-5 fail, display the form back with the user input intact. What I found to be not quite easy was how to push a different CAPTCHA into an already submitted form. (A spoiler: this is done quite smoothly with the power of ProcessWire's Inputfields.) Let's start, then. My Form class has several methods: appendFields() accepts an array of field names, gets their Inputfields from a template and appends these to the form displayForm() adds a CAPTCHA and returns the form's HTML processForm() checks the CSRF session ID and user input and delegates CAPTCHA verification getCAPTCHA() returns the html for the CAPTCHA checkCAPTCHA() checks the user input against the CAPTCHA and sets the verification flag to true or false. That's mostly it. Now to the code itself. class Form { public $form; public $captchaVerificationResult; // captcha verification flag (bool) public function __construct () { // form is created upon class instantiation $form = wire('modules')->get("InputfieldForm"); $form->action = wire('page')->path; $form->method = 'post'; $form->attr("id+name", 'form'); $form->attr("class", 'pure form'); // I use PureCSS class name here as an example // how form items are displayed can be customized $form->setMarkup(array ( 'list' => "\n{out}\n", 'item' => "\n\t{out}\n\t", 'item_label' => "\n\t\t<label class='pure-form' for='{for}'>{out}</label>", 'item_content' => "\n\t{out}\n\t", 'item_error' => "\n<p><span class='ui-state-error'>{out}</span></p>", 'item_description' => "\n<p class='description'>{out}</p>", 'item_head' => "\n<h2>{out}</h2>", 'item_notes' => "\n<p class='notes'>{out}</p>", ) ); // form classes can also be customized $form->setClasses(array ( 'list' => 'Inputfields', 'list_clearfix' => 'ui-helper-clearfix', 'item' => '', 'item_required' => '', 'item_error' => 'ui-state-error InputfieldStateError', 'item_collapsed' => '', 'item_column_width' => '', 'item_column_width_first' => '', ) ); $this->form = $form; } public function appendFields ($fields) { /* * $fields is an array of field names * * for each field name a corresponding Inputfield is fetched from a page * and appended to the form * */ $page = wire('pages')->get("999999999"); // this is the page that has your fields foreach ($fields as $f_name) { $field = wire('fields')->get($f_name); $if = $field->getInputfield($page); // this page must have field name $f_name among its fields! $this->form->append($if); } /* * * CAPTCHA placeholder */ /* * create an InputfieldMarkup field, * give it an ID and append to the form * * Later this Inputfield can be easily found by its ID. * * */ $inputfield = new InputfieldMarkup; // inputfield markup is appendable to form! $inputfield->id = 'captcha1'; // id of the InputfieldMarkup with CAPTCHA $this->form->append($inputfield); /** * finally, the SUBMIT button * */ $submit = wire('modules')->get('InputfieldSubmit'); $submit->skipLabel = Inputfield::skipLabelBlank; // remove the label $submit->name = 'submit_save'; $submit->value = "Save"; $this->form->append($submit); } public function get () { return $this->form; } public function displayForm ($form) { /* * Each time the form is displayed, the CAPTCHA should be there * * So, behore doing $form->render() let's get an InputFieldMarkup field by ID * and pour some fresh CAPTCHA in it * * */ $form->children->findOne("id=captcha1")->value .= $this->getCAPTCHA(); return $form->render(); } public function processForm ($form) { try { $form->processInput(wire('input')->post); wire('session')->CSRF->validate(); } catch (WireCSRFException $e) { die ($this->displayForm($form)); } $this->checkCAPTCHA(); // sets class property $captcha_verification_result to false/true if (!$this->captcha_verification_result) { $form->children->findOne("id=captcha1")->value = "Wrong captcha, try again <br />"; // this will go before the CAPTCHA code die($this->displayForm($form)); } else { // let's do some simple checks // you can and should do more of yours, of course $email = $form->get("b_email"); if (filter_var($email->value, FILTER_VALIDATE_EMAIL)) { $email->error = "Incorrect email format"; } if ($form->getErrors()) { // the form contains errors, display it with user input die($this->displayForm($form)); } else { echo "Thanks for the submission!"; // everything is just right } } } public function getCAPTCHA () { /* * * $captcha_html = your CAPTCHA code * */ return $captcha_html; // have a lovely CAPTCHA } public function checkCAPTCHA () { /* * * get some response and check it * * */ if ($response->failed) { $this->captchaVerificationResult = false; } else { $this->captchaVerificationResult = true; } } } Here's how this can be used: $form = new Form(); $formFields = array ("name", "email"); $form->appendFields($formFields); $newForm = $form->get(); if ($input->post->submit_save) { // user submitted the form, process it and check for errors $form->processForm($newForm); // the form was processed successfully because nothing die()'d. Now it's time to play with what's been submitted. } else { echo $form->displayForm($newForm); // if it's not been submitted, just display it and the CAPTCHA } With this being just a generic idea on how to do form processing with CAPTCHA, I hope portions of this code will prove helpful in your development. Your comments, corrections and suggestions are very much welcome.
  9. Hi, so, my first post. Really excited about processwire. I have basic understanding of php and jquery (and I mean really basic), so I thought I understood the concept fairly well. But I hit the wall with forms or any form of collecting user input. I've read a lot of posts including Soma's post about forms. It works, but I don't understand how and why. I think the best way to state my question is: how do you get the value from the input field and save it to another page (superuser only for example). Is it $fields or $input or something else entirely? If so how and where PW saves it for retrieval? For example if 10 unregistered users left 10 comments, how will I output them on the page? Or remove some of them? Also I've seen render() method a lot. How does this work? Thanks.
  10. Hi all, I want to process a form, and display an error message under certain conditions. I know there are other ways of doing this, but I kind of like the idea of using $session->set and $session->get to store and retrieve my error messages. This is the first time I have used $session->set(). Is this method ok? <?php $error = $session->get($errorMsg); echo $error; // Clear the session variable so it doesn't display again if the page is reloaded. $session->set($errorMsg, ""); // If the submit button is clicked, process the form. if($input->post->submit) { $test = $sanitizer->textarea($input->post->test); if($test==""){ $error = "Error: You left it blank!"; } elseif($test=="poop"){ $error = "Error: Poop is not allowed!"; } else { $error = ""; } $session->set($errorMsg, $error); $session->redirect('./'); // If the submit button hasn't been clicked, render the form. } else { echo "<form action='./' method='post'> <fieldset> <legend>Testing a form with validation...</legend> <div class='row'> <div class='large-12 columns'> <textarea name='test' rows='10'></textarea> </div> </div> <div class='row'> <div class='large-12 columns'> <button class='small' type='submit' name='submit' value='Send'>Test</button> </div> </div> </fieldset> </form> "; }
  11. Hello, I've been using ProcessWire for over a year now. It's wonderful to work with ProcessWire and enjoy the freedom it provides. I've used PW for tons of projects and now I've started using it for much complex projects such as invoicing applications and PM tools. The only problem I've faced so far is creating public side forms with tons of fields that need validation and processing. I've been doing it manually, writing jQuery validations, form processors and then using PW's API to store information coming from client side. It works but takes a lot of time. A friend of mine uses Drupal, he seems to be able to create client side application of same sort without having to manually process any form, with AJAX support too. I'm not complaining in anyway. I'm well aware that PW has a very strong backend that works just like(for me, even better than) Drupal. But it can't be given to public/client to use for doing form related works. I'm interested in knowing how others are handling this and what I'm doing wrong exactly? Have I missed something? I'm just looking to find a way to make forms processing less and less manual. Like I'll just create a template with set of fields, and some way to have a form of those fields created. Just like it happens at admin side. Thanks.
  12. Good Morning Everyone! As you know, we're a proud Processwire website that (thanks to this awesome CMS) hasn't looked back since moving from WordPress. We're so pleased, we're launching a couple of new sites also based on the same feel that Mr. Amazing (Ryan) developed. (For future reference, he shall now henceforth be referred to as Mr. Amazing whenever I write a post). I'm planning out the upcoming 2014 Critics' Choice CMS Awards and would love to hear some creative thoughts as to how to use Processwire (or some other method) to come up with a creative voting and nominations process. Last year, I used FormBuilder and made a simple form that people needed to submit and while it worked fine, I'm wondering if there's a better solution that might be a bit more engaging. I'd love to hear anyone's ideas / thoughts as to what options might be out there. Thanks in advance for your time! ~Mike (ps: processwire rocks)
  13. Hi, I've been struggling with building forms with the API this week-end. How would i translate the form errors messages (Missing require value...) ? Thank you.
  14. hi everyone:) i stumpled across ProcessWire on my way to learn ModX. It draws my attention because of it's fast backend, and the chance for me to connect it with my big wish to learn php (atm i know just very basic stuff :- ). PW seems to enable me to use some php-funktions with an easier layer on top of it. so, i can be productive at the beginning here are some questions, that i came up with at my exploration of the PW-wonderland in the last days: search: afaik there is the possibility to integrate a search function to the website. is it possible to combine a searchfield with checkbox filters to search and filter pages in a specific branche of the page tree? blogging: it's possible to build a tag-cloud for a blogging sections with PW. this hole filter possiblities-thing is somewhat unclear for me atm comments-module: the comments containing a name and an e-mail field, but i like to extend it with a "twitter" and "your website" field. is this possible without a lot of complicated "core hacking" ? forms: from what i have understand, it's possible to create a front-end form that collects data for the content of a page. are ther possibilities to get form entries per mail with csv-file attached or csv-styled text inside? demo page: maybe i've just overlooked it, but i was not able to find the skyscraper siteprofil on the download page. i realy like to have a look at it, to learn from the api usage there. does someone have experience with forums and newslettersystems, that go well along with PW ?(same userbase/passwords) (i hope my english was understandable, since i normaly don't write a lot in english myself. but i'm able to perfectly read and understand it). greetings, chris EDIT: a questions to the modx users in this his forum: is PW now your primary cms and modx a fallback for some special usecases? - PW made me desinterested to learn modx, but maybe i miss something
  15. Using the FormTemplateProcessor module, is it possible to have the user redirected to a different thank-you page after having successfully submitted the form?
×
×
  • Create New...