Welcome, Guest
Username: Password: Remember me

TOPIC: Where do I put the get code to autofill a field?

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
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?
The administrator has disabled public write access.

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
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
..
The administrator has disabled public write access.

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
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>
The administrator has disabled public write access.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
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 administrator has disabled public write access.
The following user(s) said Thank You: jonathanbell

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
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.
The administrator has disabled public write access.

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
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?
The administrator has disabled public write access.

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Actually it doesn't matter what the original date and time was it seems to be stuck on 21-06-2015 05:51:56
The administrator has disabled public write access.

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

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
Never mind - My mistake , added the appropriate code but failed to delete the original line I was supposed to update. Sorry
The administrator has disabled public write access.
Time to create page: 0.066 seconds

Get Started