Ejemplo n.º 1
0
 /**
  * Define form attributes (id, method, action)
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     parent::_prepareForm();
     $this->_form->setId('edit_form');
     $this->_form->setMethod('post');
     $this->_form->setAction($this->getUrl('sales/*/addressSave', array('address_id' => $this->_getAddress()->getId())));
     $this->_form->setUseContainer(true);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Prepare Form and add elements to form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     $this->setJsVariablePrefix('shippingAddress');
     parent::_prepareForm();
     $this->_form->addFieldNameSuffix('order[shipping_address]');
     $this->_form->setHtmlNamePrefix('order[shipping_address]');
     $this->_form->setHtmlIdPrefix('order-shipping_address_');
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Test \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address::_prepareForm() indirectly.
  */
 public function testGetForm()
 {
     $expectedFields = ['prefix', 'firstname', 'middlename', 'lastname', 'suffix', 'company', 'street', 'city', 'country_id', 'region', 'region_id', 'postcode', 'telephone', 'fax', 'vat_id'];
     $form = $this->_addressBlock->getForm();
     $this->assertEquals(1, $form->getElements()->count(), "Form has invalid number of fieldsets");
     /** @var \Magento\Framework\Data\Form\Element\Fieldset $fieldset */
     $fieldset = $form->getElements()[0];
     $this->assertEquals(count($expectedFields), $fieldset->getElements()->count(), "Form has invalid number of fields");
     /** @var \Magento\Framework\Data\Form\Element\AbstractElement $element */
     foreach ($fieldset->getElements() as $element) {
         $this->assertTrue(in_array($element->getId(), $expectedFields), sprintf('Unexpected field "%s" in form.', $element->getId()));
     }
     /** @var \Magento\Framework\Data\Form\Element\Select $countryIdField */
     $countryIdField = $fieldset->getElements()->searchById('country_id');
     $this->assertSelectCount('option', 246, $countryIdField->getElementHtml());
 }