Пример #1
0
 public function FieldList()
 {
     $items = parent::FieldList()->toArray();
     $count = 0;
     $firstSelected = $checked = "";
     $newItems = array();
     foreach ($items as $key => $item) {
         if (strpos($key, '//') !== false) {
             list($key, $title) = explode('//', $key, 2);
         } else {
             $title = $key;
         }
         if ($this->value == $key) {
             $firstSelected = " class=\"selected\"";
             $checked = " checked=\"checked\"";
         }
         $itemID = $this->ID() . '_' . ++$count;
         $extra = array("RadioButton" => "<input class=\"selector\" type=\"radio\" id=\"{$itemID}\" name=\"{$this->name}\"" . " value=\"{$key}\"{$checked} />", "RadioLabel" => "<label for=\"{$itemID}\">{$title}</label>", "Selected" => $firstSelected);
         if (is_object($item)) {
             $newItems[] = $item->customise($extra);
         } else {
             $newItems[] = new ArrayData($extra);
         }
         $firstSelected = $checked = "";
     }
     return new ArrayList($newItems);
 }
 /**
  * @return ArrayList
  */
 public function FieldList()
 {
     $items = CompositeField::FieldList()->toArray();
     $fields = new ArrayList();
     foreach ($items as $item) {
         $extra = array('Selected' => $this->value == $item->getValue());
         $item = $item->customise($extra);
         $fields->push($item);
     }
     return $fields;
 }
 public function FieldList()
 {
     $items = parent::FieldList()->toArray();
     $count = 0;
     $newItems = array();
     foreach ($items as $item) {
         if ($this->value == $item->getValue()) {
             $firstSelected = " class=\"selected\"";
             $checked = true;
         } else {
             $firstSelected = "";
             $checked = false;
         }
         $itemID = $this->ID() . '_' . ++$count;
         $extra = array("RadioButton" => FormField::create_tag('input', array('class' => 'selector', 'type' => 'radio', 'id' => $itemID, 'name' => $this->name, 'value' => $item->getValue(), 'checked' => $checked)), "RadioLabel" => FormField::create_tag('label', array('for' => $itemID), $item->getTitle()), "Selected" => $firstSelected);
         $newItems[] = $item->customise($extra);
     }
     return new ArrayList($newItems);
 }
 public function FieldList()
 {
     $items = parent::FieldList()->toArray();
     $count = 0;
     $newItems = array();
     foreach ($items as $item) {
         if ($this->value == $item->getValue()) {
             $firstSelected = true;
             $checked = true;
         } else {
             $firstSelected = false;
             $checked = false;
         }
         $itemID = $this->ID() . '_' . ++$count;
         // @todo Move into SelectionGroup_Item.ss template at some point.
         $extra = array("RadioButton" => DBField::create_field('HTMLFragment', FormField::create_tag('input', array('class' => 'selector', 'type' => 'radio', 'id' => $itemID, 'name' => $this->name, 'value' => $item->getValue(), 'checked' => $checked, 'aria-labelledby' => "title-{$itemID}"))), "RadioLabel" => DBField::create_field('HTMLFragment', FormField::create_tag('label', array('id' => "title-{$itemID}", 'for' => $itemID), $item->getTitle())), "Selected" => $firstSelected);
         $newItems[] = $item->customise($extra);
     }
     return new ArrayList($newItems);
 }
 /**
  * @param Member $member
  * @return FieldList
  **/
 public function getFields(Member $member = null)
 {
     $fields = parent::getEcommerceFields();
     $fields->push(new HeaderField('BillingDetails', _t('OrderAddress.BILLINGDETAILS', 'Billing Address'), 3));
     $fields->push(new TextField('Phone', _t('OrderAddress.PHONE', 'Phone')));
     $billingFields = new CompositeField();
     $hasPreviousAddresses = false;
     if ($member) {
         if ($member->exists() && !$member->IsShopAdmin()) {
             $this->FillWithLastAddressFromMember($member, true);
             $addresses = $member->previousOrderAddresses($this->baseClassLinkingToOrder(), $this->ID, $onlyLastRecord = false, $keepDoubles = false);
             //we want MORE than one here not just one.
             if ($addresses->count() > 1) {
                 $fields->push(SelectOrderAddressField::create('SelectBillingAddressField', _t('OrderAddress.SELECTBILLINGADDRESS', 'Select Billing Address'), $addresses));
                 $hasPreviousAddresses = true;
             }
         }
     }
     //$billingFields->push(new TextField('MobilePhone', _t('OrderAddress.MOBILEPHONE','Mobile Phone')));
     $mappingArray = $this->Config()->get("fields_to_google_geocode_conversion");
     if (is_array($mappingArray) && count($mappingArray)) {
         if (!class_exists("GoogleAddressField")) {
             user_error("You must install the Sunny Side Up google_address_field module OR remove entries from: BillingAddress.fields_to_google_geocode_conversion");
         }
         $billingFields->push($billingEcommerceGeocodingField = new GoogleAddressField('BillingEcommerceGeocodingField', _t('OrderAddress.FIND_ADDRESS', 'Find address'), Session::get("BillingEcommerceGeocodingFieldValue")));
         $billingEcommerceGeocodingField->setFieldMap($mappingArray);
         //$billingFields->push(new HiddenField('Address2', "NOT SET", "NOT SET"));
         //$billingFields->push(new HiddenField('City', "NOT SET", "NOT SET"));
     }
     //$billingFields->push(new TextField('Prefix', _t('OrderAddress.PREFIX','Title (e.g. Ms)')));
     $billingFields->push(new TextField('Address', _t('OrderAddress.ADDRESS', 'Address')));
     $billingFields->push(new TextField('Address2', _t('OrderAddress.ADDRESS2', '')));
     $billingFields->push(new TextField('City', _t('OrderAddress.CITY', 'Town')));
     $billingFields->push($this->getPostalCodeField("PostalCode"));
     $billingFields->push($this->getRegionField("RegionID", "RegionCode"));
     $billingFields->push($this->getCountryField("Country"));
     $billingFields->addExtraClass('billingFields');
     $billingFields->addExtraClass("orderAddressHolder");
     $this->makeSelectedFieldsReadOnly($billingFields->FieldList());
     $fields->push($billingFields);
     $this->extend('augmentEcommerceBillingAddressFields', $fields);
     return $fields;
 }
 public function FieldList($prependName = true)
 {
     $fields = parent::FieldList();
     if ($fields && $fields->exists()) {
         if ($this->value && (is_array($this->value) || $this->value instanceof DataObjectInterface)) {
             $value = $this->value;
         } else {
             $value = $this->record;
         }
         if ($value) {
             // HACK: Use a fake Form object to save data into fields
             $form = new Form($this->record, $this->name . '-form', $fields, new FieldList());
             $form->loadDataFrom($value);
             $fields->setForm($this->form);
             unset($form);
         }
         if ($prependName) {
             $this->prependName($fields);
         }
     }
     return $fields;
 }
 /**
  * Puts together the fields for the Order Form (and other front-end purposes).
  * @param Member $member
  * @return FieldList
  **/
 public function getFields(Member $member = null)
 {
     $fields = parent::getEcommerceFields();
     $hasPreviousAddresses = false;
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         $shippingFieldsHeader = new CompositeField(new HeaderField('SendGoodsToADifferentAddress', _t('OrderAddress.SENDGOODSTODIFFERENTADDRESS', 'Send goods to different address'), 3), new LiteralField('ShippingNote', '<p class="message warning">' . _t('OrderAddress.SHIPPINGNOTE', 'Your goods will be sent to the address below.') . '</p>'));
         if ($member) {
             if ($member->exists() && !$member->IsShopAdmin()) {
                 $this->FillWithLastAddressFromMember($member, true);
                 $addresses = $member->previousOrderAddresses($this->baseClassLinkingToOrder(), $this->ID, $onlyLastRecord = false, $keepDoubles = false);
                 //we want MORE than one here not just one.
                 if ($addresses->count() > 1) {
                     $hasPreviousAddresses = true;
                     $shippingFieldsHeader->push(SelectOrderAddressField::create('SelectShippingAddressField', _t('OrderAddress.SELECTBILLINGADDRESS', 'Select Shipping Address'), $addresses));
                 }
             }
             $shippingFields = new CompositeField(new TextField('ShippingFirstName', _t('OrderAddress.FIRSTNAME', 'First Name')), new TextField('ShippingSurname', _t('OrderAddress.SURNAME', 'Surname')));
         } else {
             $shippingFields = new CompositeField(new TextField('ShippingFirstName', _t('OrderAddress.FIRSTNAME', 'First Name')), new TextField('ShippingSurname', _t('OrderAddress.SURNAME', 'Surname')));
         }
         $shippingFields->push(new TextField('ShippingPhone', _t('OrderAddress.PHONE', 'Phone')));
         //$shippingFields->push(new TextField('ShippingMobilePhone', _t('OrderAddress.MOBILEPHONE','Mobile Phone')));
         $mappingArray = $this->Config()->get("fields_to_google_geocode_conversion");
         if (is_array($mappingArray) && count($mappingArray)) {
             if (!class_exists("GoogleAddressField")) {
                 user_error("You must install the Sunny Side Up google_address_field module OR remove entries from: ShippingAddress.fields_to_google_geocode_conversion");
             }
             $shippingFields->push($shippingEcommerceGeocodingField = new GoogleAddressField('ShippingEcommerceGeocodingField', _t('OrderAddress.Find_Address', 'Find address'), Session::get("ShippingEcommerceGeocodingFieldValue")));
             $shippingEcommerceGeocodingField->setFieldMap($mappingArray);
             //$shippingFields->push(new HiddenField('ShippingAddress2'));
             //$shippingFields->push(new HiddenField('ShippingCity'));
         } else {
         }
         //$shippingFields->push(new TextField('ShippingPrefix', _t('OrderAddress.PREFIX','Title (e.g. Ms)')));
         $shippingFields->push(new TextField('ShippingAddress', _t('OrderAddress.ADDRESS', 'Address')));
         $shippingFields->push(new TextField('ShippingAddress2', _t('OrderAddress.ADDRESS2', '')));
         $shippingFields->push(new TextField('ShippingCity', _t('OrderAddress.CITY', 'Town')));
         $shippingFields->push($this->getRegionField("ShippingRegionID", "ShippingRegionCode"));
         $shippingFields->push($this->getPostalCodeField("ShippingPostalCode"));
         $shippingFields->push($this->getCountryField("ShippingCountry"));
         $this->makeSelectedFieldsReadOnly($shippingFields->FieldList());
         $shippingFieldsHeader->addExtraClass("shippingFieldsHeader");
         $shippingFields->addExtraClass("orderAddressHolder");
         $fields->push($shippingFieldsHeader);
         $shippingFields->addExtraClass('shippingFields');
         $fields->push($shippingFields);
     }
     $this->extend('augmentEcommerceShippingAddressFields', $fields);
     return $fields;
 }