2

sayhello.phtml

<!DOCTYPE html>
<html>
 <head>
 <h2>Wholesale and Dealer Inquiries Form</h2>
 </head>
 <body>
<table align="center">
<form action="<?php echo $block- 
>getBaseUrl().'wholesaleapplication/index/post/';?>" method="post">
    <tr>
        <td><label> Business Name </label></td>
        <td> <input type="text" name="name"></td>
    </tr>
     <tr>
         <td><label> Contact Name </label></td>
         <td><input type="text" name="cname"></td>
    </tr>
     <tr>
         <td> <label> E-mail </label></td>
         <td><input type="email" name="email"></td>
    </tr>
     <tr>
         <td> <label> Address </label></td>
         <td><input type="text" name="address">
         <label> Street Address </label></td>
    </tr>
    <tr>
         <td></td>
         <td><input type="text" name="address2">
         <label> Street Address  line 2</label></td>
    </tr>
    <tr>
         <td></td>
         <td><input type="text" name="city">
         <label>city</label></td>
         <td><input type="text" name="state">
         <label>state/province</label></td>
    </tr>
     <tr>
         <td></td>
         <td><input type="text" name="zipcode">
         <label>postal zip/code</label></td>
    </tr>
    <tr>
         <td></td>
         <td><input type="text" name="areacode">
         <label>area code</label></td>
         <td><input type="text" name="phonenumber">
         <label>phone number</label></td>
    </tr>
     <tr>
         <td> <label class="form-label form-label-left form-label-auto" id="label_9" for="input_9"> Website </label></td>
         <td><input type="text" name="website"></td>
    </tr>
    <tr>
         <td> <label> Reseller Permit </label></td>
         <td><input type="text"  name="reseller"></td>
    </tr>
     <tr>
         <td> <label> Description of Business </label></td>
         <td><textarea  name="description" ></textarea></td>
    </tr>
     <tr>
         <td> <label> Additional Questions and Comments </label></td>
         <td><textarea name="additional"  ></textarea></td>
    </tr>
    <tr>
         <td> <label> click to edit </label></td>
         <td><input type="file"></td>
    </tr>
    <tr>
     <td><button  type="submit" name="submit">
          Submit
        </button></td>
    </tr>

</form>

country dropdowncode

<?php $_countries = 
Mage::getResourceModel('directory/country_collection')
loadData()
toOptionArray(false) ?>
<?php if (count($_countries) > 0): ?>
<select name="country" id="country">
    <option value="">-- Please Select --</option>
    <?php foreach($_countries as $_country): ?>
        <option value="<?php echo $_country['value'] ?>">
            <?php echo $_country['label'] ?>
        </option>
    <?php endforeach; ?>
   </select>
 <?php endif; ?>

i want drop down near zip code in phtml file where to keep this country code?

  • you have tried Magento 1 code> – Amit Bera Feb 21 '19 at 7:28
  • can you please share me magento2 code – Ashish Ramchandani Feb 21 '19 at 7:29
4

Magento already has a block class which is available to provide country dropdown.

On your phtml files call the block and you will get country dropdown

<?php $countryBlock = $block->getLayout()->createBlock('Magento\Directory\Block\Data');?>

<?= $countryBlock->getCountryHtmlSelect($defValue = null, $name = 'country_id', $id = 'country', $title = 'Country');?>

You can set default $defValue,$name,$id as per as your wise.

| improve this answer | |
  • i have to keep this code in sayhello.phtml file right? – Ashish Ramchandani Feb 21 '19 at 7:38
  • yes, just you have to paste this code – Amit Bera Feb 21 '19 at 7:40
  • thankyou it works – Ashish Ramchandani Feb 21 '19 at 7:40
  • now i have to pass this in post varilable so what will be the name of the variable – Ashish Ramchandani Feb 21 '19 at 7:42
  • +1 simple and nice @AmitBera – Prathap Gunasekaran Feb 21 '19 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.