I would love to change the ADDRESS PRESET to fit German needs of address entries.
What do I have to change to make this work in the forms, database, backend and so on.
Thank you for your support!
Nils
I would love to change the ADDRESS PRESET to fit German needs of address entries.
What do I have to change to make this work in the forms, database, backend and so on.
Thank you for your support!
Nils
Ummm .. What is really German address entries? can you give me an example ?
Hi! Yes sorry...
Ideal would be to add custom blocks like the the ones you offer as preset...
For the German address preset it would look like this:
[Street*] [Street number*]
[ Additional information ]
[Zip code*] [ City* ]
[ State* ] [ Country* ]
I want the state to be a drop-down selection.
Same with the countries off course like it is now.
All other fields can be text inputs.
Example inputs:
Sonnenallee 111
38159 Vechelde (Niedersachsen)
Germany
Thank you!
Nils
Hmm.. I don't think it would be possible to do exactly like that.
But something like below might be possible:
[street address + no]
[additional info ]
[zip code] [ city ]
[state ] [country ]
the state can be a dropdown.
Is that okay?
Yes!
That would be one step better than now!
How can I do it?
Thank you very much.
Nils
Hi Nils,
You will modify a bunch of code :) try to follow these steps
1. Edit "includes/view-functions.php" and go to line 1352. Put these code exactly below $country[193]['value'] = "Zimbabwe";
$state[0]['label'] = "State 1";
$state[1]['label'] = "State 2";
$state[2]['label'] = "State 3";
$state[0]['value'] = "State 1";
$state[1]['value'] = "State 2";
$state[2]['value'] = "State 3";
$state_markup = '';
foreach ($state as $data) {
$state_markup .= '<option value="' . $data['value'] . '">' . $data['label'] .
'</option>'."\n";
}
in first step you should set the value for "state drop down", I'm assuming you've 3 state in drop down. To add more state you should make a pair of array like this way
$state[4]['label'] = "State 4";
$state[4]['value'] = "State 4";
2. Go to around line 1418 ~ 1457, you'll find these code
$element_markup = <<<EOT
<li id="li_{$element->id}" {$error_class}>
<label class="description">{$element->title} {$span_required}</label>
<div id="li_{$element->id}_div_1">
<input id="element_{$element->id}_1" name="element_{$element->id}_1"
class="element text large" value="{$element->populated_value['element_'.$element->id.'_1']['default_value']}" type="text" />
<label for="element_{$element->id}_1">{$lang['address_street']}</label>
</div>
<div id="li_{$element->id}_div_2">
<input id="element_{$element->id}_2" name="element_{$element->id}_2"
class="element text large" value="{$element->populated_value['element_'.$element->id.'_2']['default_value']}" type="text" />
<label for="element_{$element->id}_2">{$lang['address_street2']}</label>
</div>
<div id="li_{$element->id}_div_3" class="left">
<input id="element_{$element->id}_3" name="element_{$element->id}_3"
class="element text medium" value="{$element->populated_value['element_'.$element->id.'_3']['default_value']}" type="text" />
<label for="element_{$element->id}_3">{$lang['address_city']}</label>
</div>
<div id="li_{$element->id}_div_4" class="right">
<input id="element_{$element->id}_4" name="element_{$element->id}_4"
class="element text medium" value="{$element->populated_value['element_'.$element->id.'_4']['default_value']}" type="text" />
<label for="element_{$element->id}_4">{$lang['address_state']}</label>
</div>
<div id="li_{$element->id}_div_5" class="left">
<input id="element_{$element->id}_5" name="element_{$element->id}_5"
class="element text medium" maxlength="15" value="{$element->populated_value['element_'.$element->id.'_5']['default_value']}" type="text" />
<label for="element_{$element->id}_5">{$lang['address_zip']}</label>
</div>
<div id="li_{$element->id}_div_6" class="right">
<select class="element select medium" id="element_{$element->id}_6"
name="element_{$element->id}_6">
{$country_markup}
</select>
<label for="element_{$element->id}_6">{$lang['address_country']}</label>
</div> {$guidelines} {$error_message}
</li>
EOT;
replace with these code
$element_markup = <<<EOT
<li id="li_{$element->id}" {$error_class}>
<label class="description">{$element->title} {$span_required}</label>
<div id="li_{$element->id}_div_1">
<input id="element_{$element->id}_1" name="element_{$element->id}_1"
class="element text large"
value="{$element->populated_value['element_'.$element->id.'_1']['default_value']}"
type="text" />
<label for="element_{$element->id}_1">{$lang['address_street']}</label>
</div>
<div id="li_{$element->id}_div_2">
<input id="element_{$element->id}_2" name="element_{$element->id}_2"
class="element text large"
value="{$element->populated_value['element_'.$element->id.'_2']['default_value']}"
type="text" />
<label for="element_{$element->id}_2">{$lang['address_street2']}</label>
</div>
<div id="li_{$element->id}_div_5" class="left">
<input id="element_{$element->id}_5" name="element_{$element->id}_5"
class="element text medium" maxlength="15"
value="{$element->populated_value['element_'.$element->id.'_5']['default_value']}"
type="text" />
<label for="element_{$element->id}_5">{$lang['address_zip']}</label>
</div>
<div id="li_{$element->id}_div_3" class="right">
<input id="element_{$element->id}_3" name="element_{$element->id}_3"
class="element text medium"
value="{$element->populated_value['element_'.$element->id.'_3']['default_value']}"
type="text" />
<label for="element_{$element->id}_3">{$lang['address_city']}</label>
</div>
<div id="li_{$element->id}_div_4" class="left">
<select class="element select medium" id="element_{$element->id}_4"
name="element_{$element->id}_4">
{$state_markup}
</select>
<label for="element_{$element->id}_4">{$lang['address_state']}</label>
</div>
<div id="li_{$element->id}_div_6" class="right">
<select class="element select medium" id="element_{$element->id}_6"
name="element_{$element->id}_6">
{$country_markup}
</select>
<label for="element_{$element->id}_6">{$lang['address_country']}</label>
</div> {$guidelines} {$error_message}
</li>
EOT;
I hope you are not confuse with those code
Hey redityo!
No problem... works perfectly so far, BUT:
I do not know how you guys realize the validation...
I added an additional blank option to have a "unselected" status.
How did you realize this with country drop-dow for example?
How is it done to check if a state is selected?
Here is the link: http://www.h o e f f n e r.de/kontakt/
Please delete the spacings after www ;-)
The problem is that the selected value of the drop-down
is not submitted (anymore) so the drop-down selection is
gone after click on SUBMIT-Button with preview page.
I think it is just a small variable update for the new
state input field type...
Thank you.
Nils
Hi Nils,
Sorry .. I'm not give attention for state drop down value when click "back" button in review page. You can try to replace this code (from my previous post)
$state_markup = '';
foreach ($state as $data) {
$state_markup .= '<option value="' . $data['value'] . '">' . $data['label'] .
'</option>'."\n";
}
with this one
$state_markup = '';
foreach ($state as $data){
if($data['value'] == $element->default_value){
$selected = 'selected="selected"';
}else{
$selected = '';
}
//check for populated value, use it instead of default value
if(!empty($element->populated_value['element_'.$element->id.'_4']['default_value'])){
$selected = '';
if($element->populated_value['element_'.$element->id.'_4']['default_value'] == $data['value']){
$selected = 'selected="selected"';
}
}
$state_markup .= "<option value=\"{$data['value']}\" {$selected}>{$data['label']}</option>\n";
}WORKES BEAUTIFULLY!
Thank you for that first class support!
Nils
How can I change the displayed (backoffice, emails) address
from inputs like this:
[street address + no]
[additional info ]
[zip code] [ city ]
[state ] [country ]
to:
STREET + NUMBER
ADD. INFORMATION
ZIP CITY (STATE)
COUNTRY
Thank you.
Nils
Hi Nils,
Try to insert this code to your CSS form, it should line up zip, city, state in one line.
#li_1_div_5 {
clear :both !important;
width : 35% !important;
float:left !important;
}
#li_1_div_3 {
width : 30% !important;
float:left !important;
}
#li_1_div_4 {
width : 30% !important;
float: left !important;
}
#li_1_div_6{
float: left !important;
}You must log in to post.