Welcome, Guest
Username: Password: Remember me

TOPIC: default value for a select box

default value for a select box 19 Oct 2012 08:31 #4665

When you use a select box, just in the view.html.php

$model_partner_origin_id = JModel::getInstance('Partners', 'SamplestrackingModel');
$model_partner_origin_id->addGroupBy("a.acronym");
$lists = $model_partner_origin_id->getItems();

as in the default_form.php

<?php
// Partner Origin
$field = $fieldSet;
$field->jdomOptions = array(
'list' => $this->lists
);
?>
<dt><?php echo $field->label; ?></dt>
<dd><?php echo $field->input; ?></dd>

exist any way to declare a default selected index ?
Not in the xml file !!
The administrator has disabled public write access.

Re: default value for a select box 19 Oct 2012 11:21 #4674

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Do you want to preffil the value, or a simple fallback ?

To set up a fall back, do it in the store() function of your table.
If you want to prefill a value, do it in prepareTable() in the item model, if I remember well.

You can try to set up a default value in the property box and check or not the prefill property. It is not possible for a FK, so try on a string field, and see how it works.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.099 seconds

Get Started