// Removing attribute 'preselect_country' and use 'default_value' instead

This commit is contained in:
mDeflotte committed 2012-02-22 14:27:32 +00:00
1 parent 735842b766
commit 07ebf2e2e5
9 files changed
+41 -40

No files matched your search

@@ -171,20 +171,12 @@
<option value="{$option->$input.options.id}"
{if isset($input.multiple)}
{foreach $fields_value[$input.name] as $field_value}
{if $field_value == $option->$input.options.id
|| empty($field_value)
&& isset($input.options.preselect_country)
&& isset($input.options.preselect_country)
&& $option->$input.options.id == $default_country}
{if $field_value == $option->$input.options.id}
selected="selected"
{/if}
{/foreach}
{else}
{if $fields_value[$input.name] == $option->$input.options.id
|| empty($fields_value[$input.name])
&& isset($input.options.preselect_country)
&& isset($input.options.preselect_country)
&& $option->$input.options.id == $default_country}
{if $fields_value[$input.name] == $option->$input.options.id}
selected="selected"
{/if}
{/if}
@@ -193,25 +185,16 @@
<option value="{$option[$input.options.id]}"
{if isset($input.multiple)}
{foreach $fields_value[$input.name] as $field_value}
{if $field_value == $option[$input.options.id]
|| empty($field_value)
&& isset($input.options.preselect_country)
&& isset($input.options.preselect_country)
&& $option[$input.options.id] == $default_country}
{if $field_value == $option[$input.options.id]}
selected="selected"
{/if}
{/foreach}
{else}
{if $fields_value[$input.name] == $option[$input.options.id]
|| empty($fields_value[$input.name])
&& isset($input.options.preselect_country)
&& isset($input.options.preselect_country)
&& $option[$input.options.id] == $default_country}
{if $fields_value[$input.name] == $option[$input.options.id]}
selected="selected"
{/if}
{/if}
>{$option[$input.options.name]}</option>
{/if}
{/foreach}
{/if}
+17 -2
View File
@@ -2068,9 +2068,24 @@ class AdminControllerCore extends Controller
}
else if (isset($input['lang']) && $input['lang'])
foreach ($this->_languages as $language)
$this->fields_value[$input['name']][$language['id_lang']] = $this->getFieldValue($obj, $input['name'], $language['id_lang']);
{
$fieldValue = $this->getFieldValue($obj, $input['name'], $language['id_lang']);
if (empty($fieldValue))
{
if (is_array($input['default_value']) && isset($input['default_value'][$language['id_lang']]))
$fieldValue = $input['default_value'][$language['id_lang']];
else
$this->fields_value[$input['name']] = $this->getFieldValue($obj, $input['name']);
$fieldValue = $input['default_value'];
}
$this->fields_value[$input['name']][$language['id_lang']] = $fieldValue;
}
else
{
$fieldValue = $this->getFieldValue($obj, $input['name']);
if (empty($fieldValue) && isset($input['default_value']))
$fieldValue = $input['default_value'];
$this->fields_value[$input['name']] = $fieldValue;
}
return $this->fields_value;
}
-1
View File
@@ -160,7 +160,6 @@ class HelperFormCore extends Helper
'form_id' => $this->id,
'fields' => $this->fields_form,
'fields_value' => $this->fields_value,
'default_country' => (int)$this->context->country->id,
'required_fields' => $this->getFieldsRequired(),
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
'module_dir' => _MODULE_DIR_,
+15 -11
View File
@@ -187,24 +187,36 @@ class AdminAddressesControllerCore extends AdminController
}
else if ($addr_field_item == 'lastname')
{
if (isset($customer) && !Tools::isSubmit('submit'.strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object))
$default_value = $customer->lastname;
else
$default_value = '';
$temp_fields[] = array(
'type' => 'text',
'label' => $this->l('Last name'),
'name' => 'lastname',
'size' => 33,
'required' => true,
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span>'
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span>',
'default_value' => $default_value,
);
}
else if ($addr_field_item == 'firstname')
{
if (isset($customer) && !Tools::isSubmit('submit'.strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object))
$default_value = $customer->firstname;
else
$default_value = '';
$temp_fields[] = array(
'type' => 'text',
'label' => $this->l('First name'),
'name' => 'firstname',
'size' => 33,
'required' => true,
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span>'
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span>',
'default_value' => $default_value,
);
}
else if ($addr_field_item == 'address1')
@@ -254,11 +266,11 @@ class AdminAddressesControllerCore extends AdminController
'label' => $this->l('Country:'),
'name' => 'id_country',
'required' => false,
'default_value' => (int)$this->context->country->id,
'options' => array(
'query' => Country::getCountries($this->context->language->id),
'id' => 'id_country',
'name' => 'name',
'preselect_country' => true,
)
);
$temp_fields[] = array(
@@ -272,17 +284,9 @@ class AdminAddressesControllerCore extends AdminController
'name' => 'name',
)
);
$this->fields_value['id_country'] = Configuration::get('PS_COUNTRY_DEFAULT');
}
}
if (isset($customer) && !Tools::isSubmit('submit'.strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object))
{
$this->fields_value['lastname'] = $customer->lastname;
$this->fields_value['firstname'] = $customer->firstname;
}
// merge address format with the rest of the form
array_splice($this->fields_form['input'], 3, 0, $temp_fields);
@@ -457,11 +457,11 @@ class AdminManufacturersControllerCore extends AdminController
'label' => $this->l('Country:'),
'name' => 'id_country',
'required' => false,
'default_value' => (int)$this->context->country->id,
'options' => array(
'query' => Country::getCountries($this->context->language->id),
'id' => 'id_country',
'name' => 'name',
'preselect_country' => true,
)
);
$form['input'][] = array(
+1 -1
View File
@@ -124,11 +124,11 @@ class AdminStatesControllerCore extends AdminController
'label' => $this->l('Country:'),
'name' => 'id_country',
'required' => false,
'default_value' => (int)$this->context->country->id,
'options' => array(
'query' => Country::getCountries($this->context->language->id, false, true),
'id' => 'id_country',
'name' => 'name',
'preselect_country' => true,
),
'desc' => $this->l('Country where state, region or city is located')
),
+1 -1
View File
@@ -180,11 +180,11 @@ class AdminStoresControllerCore extends AdminController
'label' => $this->l('Country:'),
'name' => 'id_country',
'required' => true,
'default_value' => (int)$this->context->country->id,
'options' => array(
'query' => Country::getCountries($this->context->language->id),
'id' => 'id_country',
'name' => 'name',
'preselect_country' => true,
)
),
array(
@@ -139,11 +139,11 @@ class AdminSuppliersControllerCore extends AdminController
'label' => $this->l('Country:'),
'name' => 'id_country',
'required' => true,
'default_value' => (int)$this->context->country->id,
'options' => array(
'query' => Country::getCountries($this->context->language->id, false),
'id' => 'id_country',
'name' => 'name',
'preselect_country' => true,
),
'desc' => $this->l('Country where the state, region or city is located')
),
@@ -215,11 +215,11 @@ class AdminWarehousesControllerCore extends AdminController
'label' => $this->l('Country:'),
'name' => 'id_country',
'required' => true,
'default_value' => (int)$this->context->country->id,
'options' => array(
'query' => Country::getCountries($this->context->language->id, false),
'id' => 'id_country',
'name' => 'name',
'preselect_country' => true,
),
'desc' => $this->l('Country where the state, region or city is located')
),