diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 4a85ffabfa9fd1cb882d1591edf6a16c70c54d1d..364d29dfa5ab14b83b054976841b3331aa5a0730 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1155,10 +1155,17 @@ class SelectionField extends FormField { return $this->getList()->getForm(); } function getSubFields() { + $fields = new ListObject(array( + new TextboxField(array( + // XXX: i18n: Change to a better word when the UI changes + 'label' => '['.__('Abbrev').']', + 'id' => 'abb', + )) + )); $form = $this->getList()->getForm(); - if ($form) - return $form->getFields(); - return array(); + if ($form && ($F = $form->getFields())) + $fields->extend($F); + return $fields; } function toString($items) { @@ -1307,9 +1314,9 @@ class TypeaheadSelectionWidget extends ChoicesWidget { foreach ($this->field->getList()->getItems() as $i) $source[] = array( 'value' => $i->getValue(), 'id' => $i->getId(), - 'info' => sprintf('%s %s', + 'info' => sprintf('%s%s', $i->getValue(), - (($extra= $i->getAbbrev()) ? "-- $extra" : '')), + (($extra= $i->getAbbrev()) ? " — $extra" : '')), ); ?> <span style="display:inline-block"> @@ -1330,6 +1337,7 @@ class TypeaheadSelectionWidget extends ChoicesWidget { $('input#<?php echo $this->name; ?>_id') .attr('name', '<?php echo $this->name; ?>[' + item['id'] + ']') .val(item['value']); + return false; } }); }); @@ -1348,8 +1356,12 @@ class TypeaheadSelectionWidget extends ChoicesWidget { function getEnteredValue() { // Used to verify typeahead fields $data = $this->field->getSource(); - if (isset($data[$this->name.'_name'])) - return trim($data[$this->name.'_name']); + if (isset($data[$this->name.'_name'])) { + // Drop the extra part, if any + $v = $data[$this->name.'_name']; + $v = substr($v, 0, strrpos($v, ' — ')); + return trim($v); + } return parent::getValue(); } } diff --git a/include/class.list.php b/include/class.list.php index 08451a298a36a15d94e9b5620967fac3a9b5ed39..a54277533d6759711bfe768ba2601672fcd2ea05 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -592,6 +592,7 @@ class DynamicListItem extends VerySimpleModel implements CustomListItem { foreach ($this->getConfigurationForm()->getFields() as $F) { $data['.'.$F->get('id')] = $F->toString($F->value); } + $data['.abb'] = (string) $this->get('extra'); return $data; }