// Removing attribute 'preselect_country' and use 'default_value' instead
This commit is contained in:
@@ -85,12 +85,12 @@
|
|||||||
$('#'+input_id).tagify({addTagPrompt: '{/literal}{l s='Add tag'}{literal}'});
|
$('#'+input_id).tagify({addTagPrompt: '{/literal}{l s='Add tag'}{literal}'});
|
||||||
$({/literal}'#{$table}{literal}_form').submit( function() {
|
$({/literal}'#{$table}{literal}_form').submit( function() {
|
||||||
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{/literal}
|
{/literal}
|
||||||
{/if}
|
{/if}
|
||||||
{assign var='value_text' value=$fields_value[$input.name][$language.id_lang]}
|
{assign var='value_text' value=$fields_value[$input.name][$language.id_lang]}
|
||||||
<input type="text"
|
<input type="text"
|
||||||
name="{$input.name}_{$language.id_lang}"
|
name="{$input.name}_{$language.id_lang}"
|
||||||
id="{if isset($input.id)}{$input.id}_{$language.id_lang}{else}{$input.name}_{$language.id_lang}{/if}"
|
id="{if isset($input.id)}{$input.id}_{$language.id_lang}{else}{$input.name}_{$language.id_lang}{/if}"
|
||||||
@@ -115,12 +115,12 @@
|
|||||||
$('#'+input_id).tagify({addTagPrompt: '{/literal}{l s='Add tag'}{literal}'});
|
$('#'+input_id).tagify({addTagPrompt: '{/literal}{l s='Add tag'}{literal}'});
|
||||||
$({/literal}'#{$table}{literal}_form').submit( function() {
|
$({/literal}'#{$table}{literal}_form').submit( function() {
|
||||||
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{/literal}
|
{/literal}
|
||||||
{/if}
|
{/if}
|
||||||
{assign var='value_text' value=$fields_value[$input.name]}
|
{assign var='value_text' value=$fields_value[$input.name]}
|
||||||
<input type="text"
|
<input type="text"
|
||||||
name="{$input.name}"
|
name="{$input.name}"
|
||||||
id="{if isset($input.id)}{$input.id}{else}{$input.name}{/if}"
|
id="{if isset($input.id)}{$input.id}{else}{$input.name}{/if}"
|
||||||
@@ -171,20 +171,12 @@
|
|||||||
<option value="{$option->$input.options.id}"
|
<option value="{$option->$input.options.id}"
|
||||||
{if isset($input.multiple)}
|
{if isset($input.multiple)}
|
||||||
{foreach $fields_value[$input.name] as $field_value}
|
{foreach $fields_value[$input.name] as $field_value}
|
||||||
{if $field_value == $option->$input.options.id
|
{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}
|
|
||||||
selected="selected"
|
selected="selected"
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{else}
|
{else}
|
||||||
{if $fields_value[$input.name] == $option->$input.options.id
|
{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}
|
|
||||||
selected="selected"
|
selected="selected"
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -193,25 +185,16 @@
|
|||||||
<option value="{$option[$input.options.id]}"
|
<option value="{$option[$input.options.id]}"
|
||||||
{if isset($input.multiple)}
|
{if isset($input.multiple)}
|
||||||
{foreach $fields_value[$input.name] as $field_value}
|
{foreach $fields_value[$input.name] as $field_value}
|
||||||
{if $field_value == $option[$input.options.id]
|
{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}
|
|
||||||
selected="selected"
|
selected="selected"
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{else}
|
{else}
|
||||||
{if $fields_value[$input.name] == $option[$input.options.id]
|
{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}
|
|
||||||
selected="selected"
|
selected="selected"
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
>{$option[$input.options.name]}</option>
|
>{$option[$input.options.name]}</option>
|
||||||
|
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -227,15 +210,15 @@
|
|||||||
{if $fields_value[$input.name] == $value.value}checked="checked"{/if}
|
{if $fields_value[$input.name] == $value.value}checked="checked"{/if}
|
||||||
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
|
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
|
||||||
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}">
|
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}">
|
||||||
{if isset($input.is_bool) && $input.is_bool == true}
|
{if isset($input.is_bool) && $input.is_bool == true}
|
||||||
{if $value.value == 1}
|
{if $value.value == 1}
|
||||||
<img src="../img/admin/enabled.gif" alt="{$value.label}" title="{$value.label}" />
|
<img src="../img/admin/enabled.gif" alt="{$value.label}" title="{$value.label}" />
|
||||||
{else}
|
{else}
|
||||||
<img src="../img/admin/disabled.gif" alt="{$value.label}" title="{$value.label}" />
|
<img src="../img/admin/disabled.gif" alt="{$value.label}" title="{$value.label}" />
|
||||||
{/if}
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
{$value.label}
|
{$value.label}
|
||||||
{/if}
|
{/if}
|
||||||
</label>
|
</label>
|
||||||
{if isset($input.br) && $input.br}<br />{/if}
|
{if isset($input.br) && $input.br}<br />{/if}
|
||||||
{if isset($value.p) && $value.p}<p>{$value.p}</p>{/if}
|
{if isset($value.p) && $value.p}<p>{$value.p}</p>{/if}
|
||||||
@@ -287,20 +270,20 @@
|
|||||||
<select name="{$key}" class="">
|
<select name="{$key}" class="">
|
||||||
<option value="">-</option>
|
<option value="">-</option>
|
||||||
{if $key == 'months'}
|
{if $key == 'months'}
|
||||||
{*
|
{*
|
||||||
{l s='January'}
|
{l s='January'}
|
||||||
{l s='February'}
|
{l s='February'}
|
||||||
{l s='March'}
|
{l s='March'}
|
||||||
{l s='April'}
|
{l s='April'}
|
||||||
{l s='May'}
|
{l s='May'}
|
||||||
{l s='June'}
|
{l s='June'}
|
||||||
{l s='July'}
|
{l s='July'}
|
||||||
{l s='August'}
|
{l s='August'}
|
||||||
{l s='September'}
|
{l s='September'}
|
||||||
{l s='October'}
|
{l s='October'}
|
||||||
{l s='November'}
|
{l s='November'}
|
||||||
{l s='December'}
|
{l s='December'}
|
||||||
*}
|
*}
|
||||||
{foreach $select as $k => $v}
|
{foreach $select as $k => $v}
|
||||||
<option value="{$k}" {if $k == $fields_value[$key]}selected="selected"{/if}>{l s=$v}</option>
|
<option value="{$k}" {if $k == $fields_value[$key]}selected="selected"{/if}>{l s=$v}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|||||||
@@ -2068,9 +2068,24 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
else if (isset($input['lang']) && $input['lang'])
|
else if (isset($input['lang']) && $input['lang'])
|
||||||
foreach ($this->_languages as $language)
|
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
|
||||||
|
$fieldValue = $input['default_value'];
|
||||||
|
}
|
||||||
|
$this->fields_value[$input['name']][$language['id_lang']] = $fieldValue;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$this->fields_value[$input['name']] = $this->getFieldValue($obj, $input['name']);
|
{
|
||||||
|
$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;
|
return $this->fields_value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ class HelperFormCore extends Helper
|
|||||||
'form_id' => $this->id,
|
'form_id' => $this->id,
|
||||||
'fields' => $this->fields_form,
|
'fields' => $this->fields_form,
|
||||||
'fields_value' => $this->fields_value,
|
'fields_value' => $this->fields_value,
|
||||||
'default_country' => (int)$this->context->country->id,
|
|
||||||
'required_fields' => $this->getFieldsRequired(),
|
'required_fields' => $this->getFieldsRequired(),
|
||||||
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
|
'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'),
|
||||||
'module_dir' => _MODULE_DIR_,
|
'module_dir' => _MODULE_DIR_,
|
||||||
|
|||||||
@@ -187,24 +187,36 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else if ($addr_field_item == 'lastname')
|
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(
|
$temp_fields[] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('Last name'),
|
'label' => $this->l('Last name'),
|
||||||
'name' => 'lastname',
|
'name' => 'lastname',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span>'
|
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span>',
|
||||||
|
'default_value' => $default_value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ($addr_field_item == 'firstname')
|
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(
|
$temp_fields[] = array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'label' => $this->l('First name'),
|
'label' => $this->l('First name'),
|
||||||
'name' => 'firstname',
|
'name' => 'firstname',
|
||||||
'size' => 33,
|
'size' => 33,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span>'
|
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer"> </span>',
|
||||||
|
'default_value' => $default_value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ($addr_field_item == 'address1')
|
else if ($addr_field_item == 'address1')
|
||||||
@@ -254,11 +266,11 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
'label' => $this->l('Country:'),
|
'label' => $this->l('Country:'),
|
||||||
'name' => 'id_country',
|
'name' => 'id_country',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
'default_value' => (int)$this->context->country->id,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => Country::getCountries($this->context->language->id),
|
'query' => Country::getCountries($this->context->language->id),
|
||||||
'id' => 'id_country',
|
'id' => 'id_country',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'preselect_country' => true,
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$temp_fields[] = array(
|
$temp_fields[] = array(
|
||||||
@@ -272,17 +284,9 @@ class AdminAddressesControllerCore extends AdminController
|
|||||||
'name' => 'name',
|
'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
|
// merge address format with the rest of the form
|
||||||
array_splice($this->fields_form['input'], 3, 0, $temp_fields);
|
array_splice($this->fields_form['input'], 3, 0, $temp_fields);
|
||||||
|
|
||||||
|
|||||||
@@ -457,11 +457,11 @@ class AdminManufacturersControllerCore extends AdminController
|
|||||||
'label' => $this->l('Country:'),
|
'label' => $this->l('Country:'),
|
||||||
'name' => 'id_country',
|
'name' => 'id_country',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
'default_value' => (int)$this->context->country->id,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => Country::getCountries($this->context->language->id),
|
'query' => Country::getCountries($this->context->language->id),
|
||||||
'id' => 'id_country',
|
'id' => 'id_country',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'preselect_country' => true,
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$form['input'][] = array(
|
$form['input'][] = array(
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ class AdminStatesControllerCore extends AdminController
|
|||||||
'label' => $this->l('Country:'),
|
'label' => $this->l('Country:'),
|
||||||
'name' => 'id_country',
|
'name' => 'id_country',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
'default_value' => (int)$this->context->country->id,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => Country::getCountries($this->context->language->id, false, true),
|
'query' => Country::getCountries($this->context->language->id, false, true),
|
||||||
'id' => 'id_country',
|
'id' => 'id_country',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'preselect_country' => true,
|
|
||||||
),
|
),
|
||||||
'desc' => $this->l('Country where state, region or city is located')
|
'desc' => $this->l('Country where state, region or city is located')
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -180,11 +180,11 @@ class AdminStoresControllerCore extends AdminController
|
|||||||
'label' => $this->l('Country:'),
|
'label' => $this->l('Country:'),
|
||||||
'name' => 'id_country',
|
'name' => 'id_country',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'default_value' => (int)$this->context->country->id,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => Country::getCountries($this->context->language->id),
|
'query' => Country::getCountries($this->context->language->id),
|
||||||
'id' => 'id_country',
|
'id' => 'id_country',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'preselect_country' => true,
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
|||||||
@@ -139,11 +139,11 @@ class AdminSuppliersControllerCore extends AdminController
|
|||||||
'label' => $this->l('Country:'),
|
'label' => $this->l('Country:'),
|
||||||
'name' => 'id_country',
|
'name' => 'id_country',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'default_value' => (int)$this->context->country->id,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => Country::getCountries($this->context->language->id, false),
|
'query' => Country::getCountries($this->context->language->id, false),
|
||||||
'id' => 'id_country',
|
'id' => 'id_country',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'preselect_country' => true,
|
|
||||||
),
|
),
|
||||||
'desc' => $this->l('Country where the state, region or city is located')
|
'desc' => $this->l('Country where the state, region or city is located')
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -215,11 +215,11 @@ class AdminWarehousesControllerCore extends AdminController
|
|||||||
'label' => $this->l('Country:'),
|
'label' => $this->l('Country:'),
|
||||||
'name' => 'id_country',
|
'name' => 'id_country',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'default_value' => (int)$this->context->country->id,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => Country::getCountries($this->context->language->id, false),
|
'query' => Country::getCountries($this->context->language->id, false),
|
||||||
'id' => 'id_country',
|
'id' => 'id_country',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'preselect_country' => true,
|
|
||||||
),
|
),
|
||||||
'desc' => $this->l('Country where the state, region or city is located')
|
'desc' => $this->l('Country where the state, region or city is located')
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user