Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Where do I put the get code to autofill a field? 19 Jun 2015 23:13 #13282

I have seen The following used to pre load a text box and have tried various ways to put this in the code below but I cannot get it to work?? I know I have asked this before but really need some help.. Its probably quite simple for someone who knows how to code..

value="<?php echo $_GET["entered"]; ?>


I have made it create a simple input box which it does update the field. I want to get this into the code below somehow ??

<input autocomplete='off' class='loginInput' tabindex='3' type="text" name="company" id="company" value="<?php echo $_GET["entered"]; ?>


Where do I put it so the drop down field auto fills with the $_Get??? Please help.
<?php
	// Incidentid
	$field = $fieldSet['jform_incidentid'];
	$field->jdomOptions = array(
		'list' => $this->lists['fk']['incidentid']
			);
		
	?>
	<div class="control-group <?php echo 'field-' . $field->id . $field->responsive ; ?>">
		<div class="control-label">
			<?php echo $field->label; ?>
		</div>
	
	    <div class="controls">
	   			<?php echo $field->input ; ?>
					</div>

Thanks in advance?

Please Log in or Create an account to join the conversation.

Where do I put the get code to autofill a field? 20 Jun 2015 06:51 #13283

Ive also tried
<?php echo $field->input; ?> autocomplete='off' value="<?php echo $_GET["entered"]; ?>"; ?>

This places the script autocomplete='off' value="<?php echo $_GET["entered"]; ?>"; ?> on the page after the input box

Ive tried

line 145
<?php echo $field->inputautocomplete='off' value="<?php echo $_GET["entered"]; ?>"; ?>>

but I get an error,

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/safereco/public_html/test/components/com_safety101/views/actionsitem/tmpl/actionsitem_form.php on line 145

..

Please Log in or Create an account to join the conversation.

Where do I put the get code to autofill a field? 20 Jun 2015 10:30 #13284

Ok I think I am nearly there but now the field does not show..?? Any ideas people????
<?php
	// incident
$field = $fieldSet['jform_incident'] ;
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
    <?php echo $field->label; ?>
</dIv>
<div class="controls">
<?php
$current_field = $field->input;
$current_field_input = str_replace('/>', '', $current_field);
$current_field_input = str_replace('>', '', $current_field);
?>
<?php echo $current_field_input; ?> autocomplete='off' value="<?php echo (isset($_GET["entered"])) ? $_GET["enter"] : ""; ?>"?/>

		</div>
	</div>

Please Log in or Create an account to join the conversation.

Where do I put the get code to autofill a field? 20 Jun 2015 13:40 #13286

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
first, never use that directly : $_GET["entered"]

This is a basic of Joomla to avoid injections:
$input = JFactory::getApplication()->input;
$entered = $input->get('entered');

Then, look attentively your code because you have a question mark '?' inside your marker before closing it.

Also, this is not really the correct place. Personnally I would putted that in the loadFormData() function of the model.
See the example when you set a default value for a field, and set the option 'prefills form'. It will add the specific code in the model in the loadFormData() function.
$data->company = $jinput->get('entered', null);

Hope it helps.
Coding is now a piece of cake
The following user(s) said Thank You: jonathanbell

Please Log in or Create an account to join the conversation.

Where do I put the get code to autofill a field? 21 Jun 2015 05:45 #13289

Hi, thanks. As a beginner coder I really appreciate your advice. I will go fix my code to stop injections and give what you have told me a go. I really do appreciate all and any help. Thanks again.

Please Log in or Create an account to join the conversation.

Where do I put the get code to autofill a field? 21 Jun 2015 06:50 #13290

Thanks, that inputs the code and much easier and safer as you said, than what I was originally doing. Just one little problem

I am using the created_date as

dd-mm-yyyy hh:mm:ss

- When taking the unix time stamp from the URL to place into the new form it changes the time

From the original entry it has the date and time as 18-06-2015 09:01:45

When it enters into the field from the model file it changes the time -- 21-06-2015 05:51:56

I added the code
$data->incident = $jinput->get('entered', null);

It looks to have set the original time in GMT.. The time on the action form looks to be CDT

Is there anything else I need to add to the above code to get the fields match?

Please Log in or Create an account to join the conversation.

Where do I put the get code to autofill a field? 21 Jun 2015 07:22 #13291

Actually it doesn't matter what the original date and time was it seems to be stuck on 21-06-2015 05:51:56

Please Log in or Create an account to join the conversation.

Where do I put the get code to autofill a field? 21 Jun 2015 08:10 #13292

Never mind - My mistake , added the appropriate code but failed to delete the original line I was supposed to update. Sorry

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.071 seconds

Les générateurs de code je les connais presque tous pour les avoir essorés en long en large et en travers ... mais celui ci c'est vraiment un outil formidable de simplicité et d'efficacité !
Marc. (liubov - Forum)

Get Started