form review after submit with symfony - php

With symfony, I use widgets to display a form.
Once everything is filled and validated, I land on a "review" page where all the information the user entered appears as text (<span>). To do this, I created a formatter (instead of table, I called it "review"). The formatter spits out <span> instead of <input>
It works great for basic inputs, but when it comes to Choices, or Dates, it's not working super great... I feel there is another way to have a review page without having to write a whole page just for this?
Any ideas?

Unfortunately, I find it sad that there is no concept of displaying the data already posted on a page with Symfony.
Using getValues() to recreate the whole UI with the same exact design with the exception of using <span> instead of <input> doesn't keep the code DRY at all...
I decided to create a formatter as I mentioned in my question with adding some "if" clause to make sure everything displays correctly.

You could adjust your formatter to handle other types of form elements, or you could try using some type of lightbox before the form is submitted. But in the end, I'd just go ahead and write that extra page. Everything your trying to do sounds so much more complicated than just a separate page.

I find this approach such a hassle. Why don't you pass the result of $form->getValues() to the view and output them however you want in the template?

Related

How do I make a custom <form> element be used in place of a <form> in a pre-existing plugin?

I am customizing a theme and a plugin in Wordpress. The plugin has a button where a user can click to bring up a form where they can ask a question. I want users to use post questions through this button on this plugin, but I don't fancy the visuals on it. So I thought I'd make a form on my landing page that will post into the plugin's form. If this is a terrible idea in the long run, please feel free to let me know because I am still new to web dev.
So the goal is to create a new form whose aesthetics are to my liking but still use the plugin's built in posting capability. How do I make my form paste into the plugin's form and then submit it? You'll notice that my form has 1 additional field: the add money field. I also need to integrate this into the plugin. If anyone know how to begin modifying the code for this I'm all ears to anything I need to start reading or a general way of how to approach this.
My form
Plugin's form
Summary:
Need to have my form paste to plugn form and submit
Need to add a field to the plugin code that my form can post to similar to how the other fields will do do
You can post from a different form if you get the destination URL or javascript that is handling the original form post. You can use the debugger in Firefox or Chrome to inspect the page contents to see how the form is handled.
Adding the money field will be more complicated because you will need to update the server side handling to accept the additional parameter so that it is not simply ignored or causing errors. How much work this is depends on what the server has to do. It may involve adding a column to the database or creating a new table which you will likely want to do the wordpress way if you want to have something that is maintainable.
Lastly keep in mind, that every time the original plugin is updated, it may bust your add on code unless you create your own plugin from the original.

How can I capture a form textarea value in WordPress and insert into mysql?

I see all sorts of people asking this but no solid answers. I want to take text from a textarea form where users can enter their bio and then insert it into the bio field in mysql. This might be fairly easy normally, but alas, it seems nearly impossible with WordPress. I have to use the "Php for posts and pages" plugin and for some reason, the php script I have cannot be found (404 error) no matter where I place it. Then I thought I would try to just make the form and php all on one WordPress page, but it apparently can't be done like on a normal php web page. Anyone have any experience doing this? Any approaches that are known to work?
You can make form using normal php and insert it into mysql.
You can do this by making page template in wordpress.
http://codex.wordpress.org/Page_Templates
I've went through the same process! :)
My solution was:
Installing a PHP insertor plugin (specifically this). It's lot easier than creating a template.
I used it like this (inserted into the post's source):
[insert_php] include('myphpfile.php'); [/insert_php]
Then the included PHP's contents will be processed and printed out inside the page's body (the article's main part), so you don't have to create the html, head and body tags.
Then came the problem with posting form data to a page like this. This was because some of my form's fields kinda conflicted with WP's variables.
Some of the conflicting field names I've noticed: info, name
Just have a look at your form' field names and replace them to something else, and everything will be fine! :)
PS.: It's possible to put the form and the form data "receiver" in the same PHP script. I've done so and it worked in this scenario.
PS. 2: Optionally, you can disable the annoying auto-paragraph-insertor wpautop stock WP plugin, as it's affecting the included PHP's output. There is a per-post wpautop disabler plugin: Toggle wpautop

-jQuery Form plugin- Working with multiple targets / data

I'm working with the jQuery Form plugin and was not able to find a solution for the following issue in their API:
With .ajaxForm i want to retrieve 3 or more fields out of a database. The content of each field should be written in 3 matching elements on index.php. I can get and write a single field by using
target: '#element1'
in my javascript file and by using
echo $content ;
in the matching php-script.
So how can i return more data in a single script? My thought was to return an array, but i have no idea how i target the different elements.
Well, once more, i figured it out.
So if there anytime someone will be who is trying to:
Fill a HTML Form with Database content without refreshing the Page
Here is how it can be done:
You'll need the following:
The html with the form you want to fill
The PHP script which gets your data from the database
The jQuery script which is handling both
I hope i did not miss something, got quite a headache after this. Feel free to ask.

Creating a span in an input field like Facebook messages

All,
I'm trying to create the same type of functionality that works with the Facebook messages. I'd like to basically have a list of spans (i'm guessing they do something like that) in an input textbox followed by the little to close it out.
Does anyone know how to create something like that?
Thanks in advance!
It's the tag and autocomplete textfield. You might want to check the plugin called chosen:
http://harvesthq.github.com/chosen/
or, this plugin, I think it's more relevant:
http://textextjs.com/
It's not actually an <input>. It's actually a list <ul> with a leading <input> for typing. Whatever you type, it appends to the list behind it, depending on the auto complete options.
there are several attempts to do this, found here:
http://ajaxian.com/archives/facebook-style-input-box

Editing information from a MYSQL database from website frontend.

I wonder is someone can help, I'm building a website, which is driven from a database. It will consist of user submitted information.
Currently all the information is pulled from a record in the database and is being output via a PHP echo, what i would like too do is add a feature that would allow me to edit the information if incorrect from the websites front end.
I have seen many websites have some form of edit icon next to information in there databases, when clicking this icon the echoed text changes from text to a text field and you are able to update the field being echoed from the database.
Im a designer so have limited knowledge of how functionality for this kinda feature might work.
please could anyone let me know how something like this might be achieved.
many thanks.
You would need to build some kind of javascript functionality to allow the in-place editing of those data bits. One possible solution is a jQuery plugin like jEditable.
Then you need to build a server-side script in something like PHP or ruby where it would take the submitted information and update the database.
well the process is the same for the front-end and back-end. it depends whether you want you build a password protected editable forms or just editable for everyone.
One way you can do this is
echo your information into text inputs
give them a css class that removes the border and makes it transparent
make it readonly(so someone couldnt tab into it and change it)
add a javascript onclick event that changes the class to a normal
text box that is not readonly
add a javascript onchange event that uses ajax to save the new
information into the database when they are done typing, or press enter
after the ajax is done turn the text box back to the first css class
EDIT also add a onblur event that changes it back as well
you could even change the cursor for the text input to a pointer instead of the default (text) cursor so that is looks like you can click on it.
.
now html5 has contenteditable attribute which you can set for elements
simple example:
www.hongkiat.com/blog/html5-editable-content/
simpler demo:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_global_contenteditable

Categories