Hi guys,
thanks for your suggestions. I had a workaround for the previous site but now for a new site I'm facing the same problem. Use case is a ecommerce site where the customer can optionally add a different shipping address than the billing address.
My idea now would be to extend the couch required-attribute.
I'm thinking of adding a "required-when=<condition>" attribute where condition would be to check a certain form field (hidden) and its value.
So it would then be something like:
Could someone give me a jumpstart as where to look and how this could be achieved? Or possibly any other ideas? I would add a ZIP but the site is currently a mess...
TA
Patrick
EDIT: It might help to see the current template ( not fully finished yet):
thanks for your suggestions. I had a workaround for the previous site but now for a new site I'm facing the same problem. Use case is a ecommerce site where the customer can optionally add a different shipping address than the billing address.
My idea now would be to extend the couch required-attribute.
I'm thinking of adding a "required-when=<condition>" attribute where condition would be to check a certain form field (hidden) and its value.
So it would then be something like:
- Code: Select all
<cms:input type="text" value="" class="form-control"
name="billing_city" required_when='alternative_billing_adrr="1" '
validator_msg='required_when=Pls enter city.'/>
Could someone give me a jumpstart as where to look and how this could be achieved? Or possibly any other ideas? I would add a ZIP but the site is currently a mess...
TA
Patrick
EDIT: It might help to see the current template ( not fully finished yet):
- Code: Select all
<?php require_once 'couch/cms.php'; ?>
<cms:no_cache />
<cms:template title="Bestellung" order="23" >
<cms:embed "templates/header_fields.inc" />
<cms:editable type="text" name="discount_description" label="Rabattbeschreibung" order="30"/>
<cms:editable name="page_intro" label="Page Intro" type="richtext" order="10"/>
<cms:editable name="page_text" label="Page Text" type="richtext" order="10"/>
</cms:template>
<cms:embed "html_header.inc" />
<body>
<cms:embed "head.inc" />
<div id="middle" class="container">
<div class="white">
<header class="page-header">
<h1><cms:show page_headline /></h1>
</header>
<div id="shop">
<div class="row">
<div class="col-md-7">
<cms:form method="post" anchor='0' class="white-row">
<cms:if page_subheadline !=''>
<p>
<strong><cms:show page_subheadline /></strong>
</p>
</cms:if>
<cms:if page_intro !=''>
<p>
<cms:show page_intro />
</p>
</cms:if>
<cms:if k_error >
<div class="k_errormessage">
<ul>
<cms:each k_error >
<li><cms:show item /></li>
</cms:each>
</ul>
</div>
</cms:if>
<h5>Lieferadresse</h5>
<!-- SHIPPIING ADDRESS -->
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Land</label>
<cms:input type="dropdown" name="country" class="form-control pointer" required='1'
opt_values="Bitte auswählen | | Deutschland | | Afghanistan | Ägypten | Aland | Albanien | Algerien |
Amerikanisch-Samoa | Amerikanische Jungferninseln | Andorra | Angola | Anguilla |
Antarktis | Antigua und Barbuda | Äquatorialguinea | Argentinien | Armenien | Aruba |
Ascension | Aserbaidschan | Äthiopien | Australien | Bahamas | Bahrain | Bangladesch |
Barbados | Belgien | Belize | Benin | Bermuda | Bhutan | Bolivien | Bosnien und Herzegowina |
Botswana | Bouvetinsel | Brasilien | Brunei | Bulgarien | Burkina Faso | Burundi | Chile | China |
Cookinseln | Costa Rica | Cote d'Ivoire | Dänemark | Deutschland | Diego Garcia | Dominica |
Dominikanische Republik | Dschibuti | Ecuador | El Salvador | Eritrea | Estland | Europäische Union |
Falklandinseln | Färöer | Fidschi | Finnland | Frankreich | Französisch-Guayana |
Französisch-Polynesien | Gabun | Gambia | Georgien | Ghana | Gibraltar | Grenada | Griechenland |
Grönland | Großbritannien | Guadeloupe | Guam | Guatemala | Guernsey | Guinea | Guinea-Bissau |
Guyana | Haiti | Heard und McDonaldinseln | Honduras | Hongkong | Indien | Indonesien | Irak | Iran |
Irland | Island | Israel | Italien | Jamaika | Japan | Jemen | Jersey | Jordanien | Kaimaninseln | Kambodscha |
Kamerun | Kanada | Kanarische Inseln | Kap Verde | Kasachstan | Katar | Kenia | Kirgisistan | Kiribati |
Kokosinseln | Kolumbien | Komoren | Kongo | Kroatien | Kuba | Kuwait | Laos | Lesotho | Lettland | Libanon |
Liberia | Libyen | Liechtenstein | Litauen | Luxemburg | Macao | Madagaskar | Malawi | Malaysia | Malediven |
Mali | Malta | Marokko | Marshallinseln | Martinique | Mauretanien | Mauritius | Mayotte | Mazedonien | Mexiko |
Mikronesien | Moldawien | Monaco | Mongolei | Montserrat | Mosambik | Myanmar | Namibia | Nauru | Nepal |
Neukaledonien | Neuseeland | Neutrale Zone | Nicaragua | Niederlande | Niederländische Antillen | Niger |
Nigeria | Niue | Nordkorea | Nördliche Marianen | Norfolkinsel | Norwegen | Oman | Österreich | Pakistan |
Palästina | Palau | Panama | Papua-Neuguinea | Paraguay | Peru | Philippinen | Pitcairninseln | Polen |
Portugal | Puerto Rico | Réunion | Ruanda | Rumänien | Russische Föderation | Salomonen | Sambia |
Samoa | San Marino | São Tomé und Príncipe | Saudi-Arabien | Schweden | Schweiz | Senegal |
Serbien und Montenegro | Seychellen | Sierra Leone | Simbabwe | Singapur | Slowakei | Slowenien |
Somalia | Spanien | Sri Lanka | St. Helena | St. Kitts und Nevis | St. Lucia | St. Pierre und Miquelon |
St. Vincent/Grenadinen (GB) | Südafrika, Republik | Sudan | Südkorea | Suriname | Svalbard und Jan Mayen |
Swasiland | Syrien | Tadschikistan | Taiwan | Tansania | Thailand | Timor-Leste | Togo | Tokelau | Tonga |
Trinidad und Tobago | Tristan da Cunha | Tschad | Tschechische Republik | Tunesien | Türkei | Turkmenistan |
Turks- und Caicosinseln | Tuvalu | Uganda | Ukraine | Ungarn | Uruguay | Usbekistan | Vanuatu | Vatikanstadt |
Venezuela | Vereinigte Arabische Emirate | Vereinigte Staaten von Amerika | Vietnam | Wallis und Futuna |
Weihnachtsinsel | Weißrussland | Westsahara | Zentralafrikanische Republik | Zypern "
validator='regex=/^(?!Bitte).*$/'
validator_msg='regex=Bitte wählen Sie ein Land aus der Liste aus.'
/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>Vorname</label>
<cms:input type="text" value="" class="form-control" name="firstname" required='1'
validator_msg='required=Bitte geben Sie Ihren Vornamen ein.'/>
</div>
<div class="col-md-6">
<label>Nachname</label>
<cms:input type="text" value="" class="form-control" name="lastname" required='1'
validator_msg='required=Bitte geben Sie Ihren Nachnamen ein.'/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Firma</label>
<cms:input type="text" value="" class="form-control" name="company"/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-9">
<label>Strasse</label>
<cms:input type="text" value="" class="form-control" name="street" required='1'
validator_msg='required=Bitte geben Sie eine Strasse ein.'/>
</div>
<div class="col-md-3">
<label>Hausnummer</label>
<cms:input type="text" value="" class="form-control" name="housenumber" required='1'
validator_msg='required=Bitte geben Sie eine Hausnummer ein.'/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label>Postleitzahl</label>
<cms:input type="text" value="" class="form-control" name="postalcode" required='1'
validator='regex=/[0-9]{5}/'
validator_msg='required=Bitte geben Sie Ihre Postleitzahl ein. | regex=Bitte geben Sie eine gültige Postleitzahl ein.'
/>
</div>
<div class="col-md-9">
<label>Stadt </label>
<cms:input type="text" value="" class="form-control" name="city" required='1'
validator_msg='required=Bitte geben Sie Ihre Stadt an.'/>
</div>
</div>
</div>
<!-- /SHIPPIING ADDRESS -->
<div class="alert alert-default shop-cart-checkout-alert">
<label class="pointer">
<input type="checkbox" id="show-hide" data-for="shop-cart-billing" onclick="addShippingAddress();"/>
ANDERE RECHNUNGSADRESSE
</label>
<input type="hidden" id="shipping_addr" value="0" />
<!-- BILLING ADDRESS -->
<div id="shop-cart-shipping">
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Land</label>
<cms:input type="dropdown" name="billing_country" class="form-control pointer" required='1'
opt_values="Bitte auswählen | | Deutschland | | Afghanistan | Ägypten | Aland | Albanien | Algerien |
Amerikanisch-Samoa | Amerikanische Jungferninseln | Andorra | Angola | Anguilla |
Antarktis | Antigua und Barbuda | Äquatorialguinea | Argentinien | Armenien | Aruba |
Ascension | Aserbaidschan | Äthiopien | Australien | Bahamas | Bahrain | Bangladesch |
Barbados | Belgien | Belize | Benin | Bermuda | Bhutan | Bolivien | Bosnien und Herzegowina |
Botswana | Bouvetinsel | Brasilien | Brunei | Bulgarien | Burkina Faso | Burundi | Chile | China |
Cookinseln | Costa Rica | Cote d'Ivoire | Dänemark | Deutschland | Diego Garcia | Dominica |
Dominikanische Republik | Dschibuti | Ecuador | El Salvador | Eritrea | Estland | Europäische Union |
Falklandinseln | Färöer | Fidschi | Finnland | Frankreich | Französisch-Guayana |
Französisch-Polynesien | Gabun | Gambia | Georgien | Ghana | Gibraltar | Grenada | Griechenland |
Grönland | Großbritannien | Guadeloupe | Guam | Guatemala | Guernsey | Guinea | Guinea-Bissau |
Guyana | Haiti | Heard und McDonaldinseln | Honduras | Hongkong | Indien | Indonesien | Irak | Iran |
Irland | Island | Israel | Italien | Jamaika | Japan | Jemen | Jersey | Jordanien | Kaimaninseln | Kambodscha |
Kamerun | Kanada | Kanarische Inseln | Kap Verde | Kasachstan | Katar | Kenia | Kirgisistan | Kiribati |
Kokosinseln | Kolumbien | Komoren | Kongo | Kroatien | Kuba | Kuwait | Laos | Lesotho | Lettland | Libanon |
Liberia | Libyen | Liechtenstein | Litauen | Luxemburg | Macao | Madagaskar | Malawi | Malaysia | Malediven |
Mali | Malta | Marokko | Marshallinseln | Martinique | Mauretanien | Mauritius | Mayotte | Mazedonien | Mexiko |
Mikronesien | Moldawien | Monaco | Mongolei | Montserrat | Mosambik | Myanmar | Namibia | Nauru | Nepal |
Neukaledonien | Neuseeland | Neutrale Zone | Nicaragua | Niederlande | Niederländische Antillen | Niger |
Nigeria | Niue | Nordkorea | Nördliche Marianen | Norfolkinsel | Norwegen | Oman | Österreich | Pakistan |
Palästina | Palau | Panama | Papua-Neuguinea | Paraguay | Peru | Philippinen | Pitcairninseln | Polen |
Portugal | Puerto Rico | Réunion | Ruanda | Rumänien | Russische Föderation | Salomonen | Sambia |
Samoa | San Marino | São Tomé und Príncipe | Saudi-Arabien | Schweden | Schweiz | Senegal |
Serbien und Montenegro | Seychellen | Sierra Leone | Simbabwe | Singapur | Slowakei | Slowenien |
Somalia | Spanien | Sri Lanka | St. Helena | St. Kitts und Nevis | St. Lucia | St. Pierre und Miquelon |
St. Vincent/Grenadinen (GB) | Südafrika, Republik | Sudan | Südkorea | Suriname | Svalbard und Jan Mayen |
Swasiland | Syrien | Tadschikistan | Taiwan | Tansania | Thailand | Timor-Leste | Togo | Tokelau | Tonga |
Trinidad und Tobago | Tristan da Cunha | Tschad | Tschechische Republik | Tunesien | Türkei | Turkmenistan |
Turks- und Caicosinseln | Tuvalu | Uganda | Ukraine | Ungarn | Uruguay | Usbekistan | Vanuatu | Vatikanstadt |
Venezuela | Vereinigte Arabische Emirate | Vereinigte Staaten von Amerika | Vietnam | Wallis und Futuna |
Weihnachtsinsel | Weißrussland | Westsahara | Zentralafrikanische Republik | Zypern "
validator='regex=/^(?!Bitte).*$/'
validator_msg='regex=Bitte wählen Sie ein Land aus der Liste aus.'
/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>Vorname</label>
<cms:input type="text" value="" class="form-control" name="billing_firstname" required='1'
validator_msg='required=Bitte geben Sie Ihren Vornamen ein.'/>
</div>
<div class="col-md-6">
<label>Nachname</label>
<cms:input type="text" value="" class="form-control" name="billing_lastname" required='1'
validator_msg='required=Bitte geben Sie Ihren Nachnamen ein.'/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Firma</label>
<cms:input type="text" value="" class="form-control" name="billing_company"/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-9">
<label>Strasse</label>
<cms:input type="text" value="" class="form-control" name="billing_street" required='1'
validator_msg='required=Bitte geben Sie eine Strasse ein.'/>
</div>
<div class="col-md-3">
<label>Hausnummer</label>
<cms:input type="text" value="" class="form-control" name="billing_housenumber" required='1'
validator_msg='required=Bitte geben Sie eine Hausnummer ein.'/>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label>Postleitzahl</label>
<cms:input type="text" value="" class="form-control" name="billing_postalcode" required='1'
validator='regex=/[0-9]{5}/'
validator_msg='required=Bitte geben Sie Ihre Postleitzahl ein. | regex=Bitte geben Sie eine gültige Postleitzahl ein.'
/>
</div>
<div class="col-md-9">
<label>Stadt </label>
<cms:input type="text" value="" class="form-control" name="billing_city" required='1'
validator_msg='required=Bitte geben Sie Ihre Stadt an.'/>
</div>
</div>
</div>
</div></div>
<!-- /BILLING ADDRESS -->
<!-- PAYMNET SELECTOR -->
<div class="alert alert-default shop-cart-checkout-alert">
<label class="pointer">
<input type="radio" name="payment_method" value="1" checked="checked" /> <strong>Direct Bank Transfer</strong>
</label>
<label class="pointer">
<input type="radio" name="payment_method" value="2" /> <strong>Cheque Payment</strong>
</label>
<label class="pointer">
<input type="radio" name="payment_method" value="3" /> <strong>Paypal</strong>
</label>
</div>
<!-- /PAYMNET SELECTOR -->
<!-- AGREE -->
<div class="row">
<div class="col-md-12">
<label class="pointer shop-cart-agree">
<input type="checkbox" name="agree" value="1" /> I understand and agree the <a href="page-terms-and-conditions.html" target="_blank">terms and conditions</a>.
</label>
</div>
</div>
<!-- /AGREE -->
<button class="btn btn-primary btn-lg"><i class="fa fa-check"></i> PLACE ORDER</button>
</cms:form>
</div>
<div class="col-md-5">
<h3><strong>Discount</strong> Code</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pellentesque neque eget diam porta.</p>
<div class="alert alert-success">
<i class="fa fa-check-circle"></i>
<strong>CODE-12345</strong> - 10% Discount!
</div>
<div class="alert alert-danger">
<i class="fa fa-frown-o"></i>
Sorry, Invalid Code!
</div>
<form class="input-group" method="post" action="#">
<input type="text" class="form-control" name="k" id="k" value="" placeholder="Enter Coupon Code" />
<span class="input-group-btn">
<button class="btn btn-primary">Apply Code</button>
</span>
</form>
<div class="shop-cart-final-payment text-right">
<hr />
<span class="block fsize13">Shipping: $0</span>
<span class="block fsize13">Discount: $0</span>
<span class="fsize20 styleSecondColor bold">TOTAL: $64</span>
</div>
</div>
</div>
</div>
</div>
</div>
<cms:embed "footer.inc" />
</body>
</html>
<?php COUCH::invoke(); ?>