1

HI I downloaded an extension (checkout-custom-form) from here, I want to modify his extension, https://github.com/sbodak/magento2-checkout-custom-form the extension itself work wonderful.

having below XML code and it will display as a text box, how do I convert into dropdown selection box?

restaurant, government, education, retailer ...etc

  <item name="checkout_industry" xsi:type="array">
 <item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
     <item name="config" xsi:type="array">
     <item name="customScope" xsi:type="string">customCheckoutForm</item>
     <item name="template" xsi:type="string">ui/form/field</item>
     <item name="elementTmpl" xsi:type="string">ui/form/element/textarea</item>
     <item name="cols" xsi:type="string">15</item>
     <item name="rows" xsi:type="string">2</item>
  </item>
      <item name="provider" xsi:type="string">checkoutProvider</item>
      <item name="dataScope" xsi:type="string">customCheckoutForm.checkout_industry</item>
      <item name="label" xsi:type="string">Industry</item>
      <item name="sortOrder" xsi:type="string">5</item>
</item>

enter image description here

custom_field.phtml

    <?php
/** @var Bodak\CheckoutCustomForm\Block\Order\CustomFields $block */

/** @var Bodak\CheckoutCustomForm\Model\Data\CustomFields $customFields */
$customFields = $block->getCustomFields($block->getOrder());
?>
<?php if($customFields): ?>
    <div class="block block-order-details-view">
        <div class="block-content">
            <div class="box">
                <strong class="box-title"><span><?php /* @escapeNotVerified */ echo __('Other information') ?></span></strong>
                <div class="box-content">
               
            </div>

            <div class="box">
                <strong class="box-title"><span><?php /* @escapeNotVerified */ echo __('Industry') ?></span></strong>
                <div class="box-content">
                    <?php echo nl2br($this->escapeHtml($customFields->getCheckoutIndustry())); ?>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>
2

1 Answer 1

0

I finally get this solve by reference this site https://www.mageplaza.com/devdocs/add-new-input-form-magento-2.html

   <item name="checkout_industry" xsi:type="array">
   <item name="component" xsi:type="string">Magento_Ui/js/form/element/select</item>
   <item name="config" xsi:type="array">
       <item name="customScope" xsi:type="string">customCheckoutForm</item>
       <item name="template" xsi:type="string">ui/form/field</item>
       <item name="elementTmpl" xsi:type="string">ui/form/element/select</item>
   </item>
       <item name="options" xsi:type="array">
           <item name="0" xsi:type="array">
               <item name="label" xsi:type="string">Please select value</item>
               <item name="value" xsi:type="string"></item>
           </item>
           <item name="1" xsi:type="array">
               <item name="label" xsi:type="string">Value 1</item>
               <item name="value" xsi:type="string">value_1</item>
           </item>
           <item name="2" xsi:type="array">
               <item name="label" xsi:type="string">Value 2</item>
               <item name="value" xsi:type="string">value_2</item>
           </item>
       </item>
   <item name="value" xsi:type="string">value_2</item>                                                                                      
   <item name="provider" xsi:type="string">checkoutProvider</item>
   <item name="dataScope" xsi:type="string">customCheckoutForm.checkout_industry</item>
   <item name="label" xsi:type="string">Select Industry</item>
   <item name="sortOrder" xsi:type="string">5</item>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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