Edit form not working with bootstrap and datepicker - php

I ve created an edit form CRUD system. It all works well apart from when i want user to be able to edit the date in the form.
The code below is the only way i can get the whole thing working with jquery datepicker, bootstrap and php. At moment the php sits outside the field i want to edit.
So, the datepicker works fine (id=date2) . if i delete the datepicker and give the php a 'value' the date appears in the field ready to be edited but the datepicker obviously doesn't work as ive taken it out of the code.
If i mix the 2 then the php doesn't call the date value into the text field, but the date picker works.
JS file:
$(" #date2" ).datepicker({dateFormat:'yy-mm-dd'}); $("#date2").val('');
<div class="form-group">
<label class="col-md-4 control-label">Date Agent Instructed</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group" >
<span class="input-group-addon" style="cursor:pointer" > <i class="glyphicon glyphicon-calendar" ></i></span>
<input type="text" style="cursor:pointer" placeholder="Click Here To Edit" readonly="readonly" name="date_instructed" id="date2" class="form-control" > <?php echo $row[14];?>

$(".date2").val('');
This piece of code (which was in my js code) is emptying your input field. If you want to keep the original value you are echoing into the field via PHP, you will need to remove this piece of jquery code as it is setting the value to nothing.
Symeon Quimby answered it on a related question,

Related

Wordpress Plugin: Where to put "maxlength="10" to limit formfield character count?

I am using the plugin "strong testimonials".
https://de.wordpress.org/plugins/strong-testimonials/
I need to limit the maximum characters a user can type in the comment form.
When inspecting my page, the form is rendered as
<textarea id="wpmtst_post_content" name="post_content" class="" required="" tabindex="0" aria-required="true" maxlength="10"></textarea>
I just need to append "maxlength="10" attribute, but since the HTML code is assembled with php, i can't find where to put it in which php file. I noticed the form fields are stored in arrays, which will be exploded upon request, but I don't know anything about PHP and can't figure out, where I have to put it.
Thanks
AO
No need to change PHP code, you can do it with javascript.
$(document).ready(function(){
$('#wpmtst_post_content').attr('maxlength',10);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="wpmtst_post_content" name="post_content" class="" required="" tabindex="0" aria-required="true"></textarea>

Link wizards in backend module in typo3-7

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

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.

PHP - Get checkbox value Twitter Bootstrap

I'm building an app using Laravel and Twitter Bootstrap. And now i've come to a point i where want to use checkboxes. Bootstrap styles the checkboxes automatically which is nice.
But in PHP i can't get the value of the checkbox to determine whether it's checked. Bootstrap seems to use "uniform" to style the checkbox. When i exclude that file i CAN get the value of the checkbox.
I do this to get the value:
$checkbox = Input::get('checkbox', function() {return 0;});
If the input has a value, use the value, else return 0.
It works fine, except when Bootstrap styles the checkbox. With jQuery it's possible to check if the span of the checkbox has the class "checked" but I want to check server-side. But Bootstrap/Uniform doesn't apply "checked" to the checkbox itself.
Are there more people that have the same problem? Or even better, does someone have the solution for this? Thanks!
On form submittal you can always check for the validation of the checkbox:
PHP Code:
<?php if(isset($_POST['$yourName'])){}; ?>
HTML Code:
<div class="form-group input-group-sm">
<label class="col-md-4 control-label" for="$yourName">Your Title</label>
<div class="col-md-1 input-group-sm">
<input id="$yourName" name="$yourName" type="checkbox" class="form-control">
</div>
</div>

JQuery UI Timepicker is not open when click the text field

I have one question regarding to JQuery UI Timepicker. I have multiple text fields.
<input type="text" style="width: 31px;" id="timepicker.[1]" name="mon1" readonly="true"/>
<input type="text" style="width: 31px;" id="timepicker.[2]" name="mon2" readonly="true"/>
<input type="text" style="width: 31px;" id="timepicker.[3]" name="mon3" readonly="true"/>
I have called the jquery function using this.
$('#timepicker\\.\\[1\\]').timepicker();
$('#timepicker\\.\\[2\\]').timepicker();
$('#timepicker\\.\\[3\\]').timepicker();
They are working. when i clicked first text field, the timepicker shows up. the same behavior goes to the second timepicker. But when i clicked third textfield, it won't show up. I have to click outside the textfield first and then click again on the third text field,after that the timepicker shows up. The same goes to the rest of text field (I have many textfields). What is the problem and may i know how to solve it?
Thanks guys,appreciate it....
Try like this
$("input[id^=timepicker]").timepicker();

Categories