Link wizards in backend module in typo3-7 - php

Help me i want to add link wizard in the backend module in front of the textfield without using TCA in typo3-7.6.9.
enter image description here

This could be possible as there has been a lot of changes regarding the JS and the form.
I quickly copied some code together which could be perfect for a base
<form name="editform">
<div class="form-wizards-element"><input type="text"
data-formengine-input-name="data[tx_news_domain_model_news][111][internalurl]"
value="" maxlength="255"
class="form-control t3js-clearable hasDefaultValue"/>
</div>
<div class="form-wizards-items">
<div class="btn-group"><a class="btn btn-default" href="#"
onclick="this.blur();vHWin=window.open('\/typo3\/index.php?route=%2Fwizard%2Flink%2Fbrowse\u0026token=970f35a8dc4409162cbcc22cbc0e6594074ac0b2\u0026P[params]=\u0026P[exampleImg]=\u0026P[table]=tx_news_domain_model_news\u0026P[uid]=111\u0026P[pid]=33\u0026P[field]=internalurl\u0026P[flexFormPath]=\u0026P[md5ID]=ID800c13a372\u0026P[returnUrl]=%2Ftypo3%2Findex.php%3Froute%3D%252Frecord%252Fedit%26token%3Db3d049b7b8bf49a7c89304b8ca24341be71120b1%26edit%5Btx_news_domain_model_news%5D%5B111%5D%3Dedit%26returnUrl%3D%252Ftypo3%252Findex.php%253FM%253Dweb_list%2526moduleToken%253D3dae7050436434ec90fe6376b230d7e43ded20c0%2526id%253D33%2526imagemode%253D1\u0026P[formName]=editform\u0026P[itemName]=data%5Btx_news_domain_model_news%5D%5B111%5D%5Binternalurl%5D\u0026P[hmac]=f1f3ba419c5ecf1bedce9656d521511cc0217a0a\u0026P[fieldChangeFunc][TBE_EDITOR_fieldChanged]=TBE_EDITOR.fieldChanged%28%27tx_news_domain_model_news%27%2C%27111%27%2C%27internalurl%27%2C%27data%5Btx_news_domain_model_news%5D%5B111%5D%5Binternalurl%5D%27%29%3B\u0026P[fieldChangeFunc][alert]=\u0026P[fieldChangeFuncHash]=c6a39ad17bdeac70cb33a3a0bccd0faa99e645c9'+'&P[currentValue]='+'&P[currentSelectedValues]=','popUpID800c13a372','height=600,width=800,status=0,menubar=0,scrollbars=1');vHWin.focus();return false;"><img
src="/typo3/sysext/backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif" alt="Link"
title="Link"/></a></div>
</div>
</form>
The popup opens and the value is written back as well to the form. However some more work needs to be done:
remove the not needed code
generate the correct token
Regarding the token, you can take a look at my news extension which uses e.g. that code
$token = FormProtectionFactory::get()->generateToken('moduleCall', 'web_NewsTxNewsM2');
I hope that helps

Related

Which Prestashop file do i modify to change the form method and form action of the search function?

I have just installed the latest version of Prestashop with the default theme named classic.
I want to change the way the search function works.
Eg. change it from get to post, and change the form action to a different location, change the type of button etc.
I have attempted to modify the following files:
public_html/modules/ps_searchbar/ps_searchbar.tpl
public_html/themes/classic/modules/ps_searchbar/ps_searchbar.tpl
both of these files contain code that looks like it controls the search function:
<div id="search_widget" class="col-lg-4 col-md-4 col-sm-12 search-widget" data-search-controller-url="//www.soccersurplus.co.uk/search">
<form method="get" action="{$search_controller_url}">
<input type="hidden" name="controller" value="search">
<input type="text" name="s" value="" placeholder="Search our catalog" aria-label="Search">
<button type="submit">
<i class="material-icons search"></i>
<span class="hidden-xl-down">Search</span>
</button>
</form>
</div>
however, when i make changes to these files, it does not effect the search function on prestashop, and even when i delete both of the files the search still works.
Which files do i need to modify to change my search function?
my website is soccersurplus.co.uk
Thanks.

Submitting html-form data and iframe input simultaneously

I have a page ( index.html ) with a form. On submit the data is posted to a php-file which then stores said data in a (temporary) xml-file, however, I also have a number of iframes which also contain forms.
At first, I was planning on simply posting the input-data from the iframes to a seperate php file but I encountered several problems:
-I have several iframes, but I don't have a fixed amount since the user is supposed to be able to delete/ add iframes. Therefore I can't just tell iframe 1 to send its data to php-file no. 1, iframe 2 to send its data to php-file no.2 etc.., I need a flexible solution.
-I tried to submit all iframe inputs to ONE php file and was hoping it'd work since the xml-file this php-file sends the data to is only updated and not completely overwritten. As you might guess, this did not work.
-Another problem I encountered is that the user may go back and edit whatever he entered into the iframe. The data should only be saved once he clicks on the save button in the html-file to prevent that.
I also tried submitting the data via JavaScript, as people in similar questions suggested, but that did not work out for me. So I guess what I would like, is a suggestion as to how I should go about this. How can I send all the data once the "main" save button is clicked, it doesn't matter if the data goes to several php files. The solution shouldn't depend on a fixed amount of elements as that amount is not always the same.
Here's the iframe-html:
<form method="POST" action="php/iframe.php">
<label>Your thoughts:</label>
<input type="text" name="header">
<label>Suggestions:</label>
<textarea type="text" name="textbox"></textarea>
<input type="button" value="submit">
</form>
(It's basically the same for all Iframes).
Please let me know if you need any additional information.
Edit: I read that submitting forms at the same time may cause interference, I know that much
Edit:
Relevant index.html:
<form method="post" action="main.php">
<div id="firstSection"
<label>First input</label>
<input type="text" name="input[]">
<button type="button" onclick="openIframe1()">Read more</button>
</div>
<div id="secondSection"
<label>Second input</label>
<input type="text" name="input[]">
<button type="button" onclick="openIframe2()">Read more</button>
</div>
<button type="submit" value="submit"></button>
</form>
<div class="iframe">
<button type="button" class="close">Close</button>
<iframe src="iframe1.html"></iframe>
</div>
<div class="iframe">
<button type="button" class="close">Close</button>
<iframe src="iframe2.html"></iframe>
</div>
Define an array of your iframe inputs in the main page as hidden element, on click submit in the main page loop through the iframe by getting the datas and append to your hidden element from where you can now post that to your back end.. try this: Access jQuery data from iframe element

Multiple forms using the action variable?

I have a page that has multiple php forms that send me different informations depending on the user and the form. How do I make php differentiat these? I saw something about the actions and I thought maybe it was like having a separate file, but when I created a "questions.php" and copied and pasted my php code into that and then added "action="questions.php"" to the tag, and ran it just as I had before it didn't work. So what is the correct way to do this?
My code is extremely long and filled with words which is why it would be nice to have separate files for it depending on the form instead of all in the top of my main page.
You could build one page as a standard page. in this page you could include the different forms. See the example below:
<!-- These are just example names -->
<div class="form-1">
<?php include "forms/form-1.php"; ?>
</div>
<div class="form-2">
<?php include "forms/form-2.php"; ?>
</div>
<div class="form-1">
<?php include "forms/form-3.php"; ?>
</div>
If you would like to save data that a user puts in a form in lets say a database you should use the <form method="post"> by adding an action to it. You're asking the form to send the user to another page when the submit button is clicked. an example of a form down below.
<form class="form-1" method="post" action="second_page.php">
<label>Name:
<input type="text" class="input" name="name">
</label>
<label>Email:
<input type="email" class="input" name="email">
</label>
<button type="submit">Send!</button>
</form>
Hope this helps!
I just added a / before the questions.php. apparently it had to do with file path? I don't understand it but it works now.
<form action="questions.php" method="post">
<!-- text boxes to get user inputs-->
<button type="submit" value="submit_btn">click here to go to page in action tag
</button>
</form>
If questions.php file is in same folder action="questions.php" is enough. If its inside 'x' folder, correct path should be given as action="x/questions.php"

Form not sending data through Post

I am implementing a simple newsletter form using PHP and CodeIgniter as part of a big project.
My HTML code is as follows.
<form method="POST" action='http://sit.com/index.php/Users/subscribenews'>
<div class="input-group">
<input type="email" id="pkemailid" name="pkemailid">
<span class="input-group-btn">
<button class="btn btn-lg btn-primary" type="submit"> Go
</button>
</span>
</div><!-- /input-group -->
</form>
In my Controller, I am handling the value as
$emailid = $this->input->post('pkemailid');
When I do a var_dump of the $_POST variable, I get the following
array(0) { }
The biggest problem is that I am able to run this correctly on my WAMP Server on localhost but it does not work on the hosted server.
Interestingly, if I change the POST to GET, then it starts working.
this line
<input type="email" id="pkemailid" name="pkemailid">
try changing it to
<input type="text" id="pkemailid" name="pkemailid">
type="email" is html 5 only and i don't know for certain -- but codeigniter might not support html 5 form values.
===== edit
so my suggestion when you are at the hair pulling questioning reality stage of trying to find a bug - get a fresh new copy of codeigniter, install on your server, make sure you get the welcome page.
now make the simplest form possible and echo something out from the controller method to make sure that you are submitting the form to the correct method. Next add a hidden form field with a value, and echo out that value from your method.
If all that works, then its not your server you have bug in your original code. And if it doesn't work then you have an issue with the server.

custom wordpress comment form html

I would like to modify the actual HTML of the comment forms in WordPress. I know of the comment_form() function that WordPress provides, but it doesn't actually let me modify the html of the form. What I'm specifically trying to do is make a bootstrap responsive form, which is not possible with the options provided with the comment_form() function. I've tried looking all over the internet for a way, but to no avail. Can anyone point me in the right direction?
Let me clarify this:
I am looking to modify the actual FORM and containing DIV elements of the comment form, not just the fields.
The uncustomizable parts of the function comment_form() should (idealistically) be limited purely to code that is essential for security and proper form handling by the WordPress core. However, that is not the case. To explore the issue, I used filters (could have used arguments) to completely remove all the code that is customizable. I set all available variables to empty strings—that is, all the stuff mentioned on the codex page for comment_form().
Here is the left-over, non-customisable code from comment_form():
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title"> <small><a rel="nofollow" id="cancel-comment-reply-link" href="/1#respond" style="display:none;">Click here to cancel reply.</a></small></h3>
<form action="http://www.[yourdomain].com/wp-comments-post.php" method="post" id="" class="comment-form">
<p class="form-submit">
<input name="submit" type="submit" id="" value="" />
<input type='hidden' name='comment_post_ID' value='1' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</p>
</form>
</div><!-- #respond -->
Where does all this come from? At the bottom of the codex page for comment_form() it says…
Source Code
comment_form() is located in wp-includes/comment-template.php.
comment-template.php is linked and you can view the full code in the browser. comment_form() starts on line 1960. In fact, it’s the last function in that file. There are no arguments or filters that let you modify the residual code above. These lines of code are all moreorless “hard-coded”.
The text Click here to cancel reply. is the only text that survived my filter genocide. Strangely, comment_form() has back-up text for cancel_reply_link hard-coded into the function, in case it is passed to the function as an empty string. None of the other filterable items have hard-coded back-ups.
It is easy to see which bits of code are essential and which bits are non-essential for a HTML form. A little more difficult to judge is which bits are essential for a WordPress form. Some of the bits above were dynamically output (note that this is the first comment on a development blog with no other replies, no parent/child comments).
From the comment_form() function in comment-template.php you can draw out the code needed to produce the dynamic parts of the WordPress form. Then, with default arguments taken from the codex page for comment_form(), you could piece together a barebones form, hard-coding the desired fields, labels and wrapping HTML. I’m doing that now and putting my custom form function in my theme’s comments.php template file, which I call using comments_template() only in single.php (for this particular theme).
The result would be a full and proper, lean and mean WordPress comment form. But… it would be a form that could not be customized anymore using comment_form() arguments or related filters unless you went ahead and included the filter code in your own comment form function. Since you’re customizing the heck out it already, that’s probably not a problem. Similarly, all the WordPress actions would also be unavailable to you or any other plugins unless you also triggered those action functions in your own comment form function. Again, probably not an issue for you at this point.
But most importantly, the resulting form might break your theme if future WordPress updates change the way the core handles forms.
If you’re aware of those risks, you can probably rebuild a hand-coded comment form just from copying code on the codex page for comment_form() and in wp-includes/comment-template.php. I don’t have the finished code, otherwise I’d post it. But I will post when/if I succeed.
Right, that’s all from me for now. Bear in mind (all readers) that despite appearances, I am an amateur WordPress theme developer and my proficiency with PHP and WordPress is very rudimentary. Just writing up this post I learned a lot.
I’m also worried that a full and proper solution is already out there somewhere but I haven’t found it in my searches.
Just Create a New PHP file with the name of comment_form.php then paste all of your code. And your comment form is ready.
you shouldn't edit the wp-includes/comment-template.php file.
Keep this for your ref for more styling your existing comment form
http://codex.wordpress.org/Template_Tags/comment_form
Or this one
http://wordpress.org/support/topic/where-to-find-the-comment_form-function-in-wp3
Form code and action
<div class="comment-form">
<h2 class="comments-wrapper-heading"> Leave a comment </h2>
<form id="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<div class="commentform-element">
<label class="hide" for="author">Full Name</label>
<input class="input-fields" id="author" name="author" type="text" placeholder="Full Name" value=""/>
</div>
<div class="commentform-element">
<label class="hide" for="author">Email</label>
<input class="input-fields" id="email" name="email" type="text" placeholder="Email" value=""/>
</div>
<div class="commentform-element">
<label class="hide" for="comment">Message</label>
<textarea id="comment" class="input-fields" placeholder="Message" name="comment" cols="40" rows="200"></textarea>
</div>
<input name="submit" class="form-submit-button" type="submit" id="submit-comment" value="Post comment">
<input type="hidden" name="comment_post_ID" value="22" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</form>
</div>
WP does not offer a way to create and use a comment form template. i.e.: as of 4.1.1, there's still no way to control all of the HTML markup that makes up the form. There are only ways to edit parts of it and that's by supplying arguments to comment_form().
So, if you would like to edit the whole layout (e.g.: place some of the content side to side instead of on top of one another; replace some of the <p>with <div>), you're out of luck.
What can we do?
An option would be to borrow the whole comment_form() function from the WordPress codebase (like this guy did): make a copy of the function in your theme, rename it, customize it and then call it in place of the vanilla function. That will work but there's a chance it might break on a future WordPress update if some of the inner workings of WP change.
Did you look for the comment_form() function in Wordpress code to see if you can edit it ?
You'll also find some informations here :
http://wordpress.org/support/topic/editing-the-comment-form
This function uses the default form. You need to make a comment-template.php file in your theme and in that file you can make your form.
Now when you will call comments_template() you will get your made form instead of default form.
I don't think you can change the containing div (<div id="respond" class="comment-respond">). Have a look at the comment-template.php
The only thing you can change is the form ID. 'id_form' => 'commentform'
You can make a responsive form without changing these elements.
I've recently answered something similiar on WPSE. You can go and check it out here

Categories