/** * (non-PHPdoc) * @see sapphire/forms/FormField#Field() */ function Field() { if ($this->isReadonly()) { $nullableCheckbox = new CheckboxField_Readonly($this->getIsNullId()); } else { $nullableCheckbox = new CheckboxField($this->getIsNullId()); } $nullableCheckbox->setValue(is_null($this->dataValue())); return $this->valueField->Field() . ' ' . $nullableCheckbox->Field() . ' <span>' . $this->getIsNullLabel() . '</span>'; }
public function Field($properties = array()) { $name = $this->getName(); if ($this->wrapFieldgroup) { $field = "<div class=\"fieldgroup\">" . "<div class=\"fieldgroup-field\">" . $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . "</div>" . "</div>"; } else { $field = $this->fieldLatitude->Field() . $this->fieldLongditude->Field(); //SmallFieldHolder() } return $field; }
/** * @return string */ function Field($properties = array()) { if (GoogleMaps::getApiKey()) { Requirements::javascript('//maps.googleapis.com/maps/api/js?js?v=3.exp&callback=initializeGoogleMaps&signed_in=true&sensor=false&libraries=places&language=' . i18n::get_tinymce_lang() . '&key=' . GoogleMaps::getApiKey()); } else { Requirements::javascript('//maps.googleapis.com/maps/api/js?v=3.exp&callback=initializeGoogleMaps&signed_in=true&sensor=false&libraries=places&language=' . i18n::get_tinymce_lang()); } Requirements::javascript('geoform/javascript/backendgeolocationfield.js'); Requirements::css('geoform/css/backendgeolocationfield.css'); return "<div class=\"fieldgroup\">" . "<div class=\"backend-geo-location-field\">" . $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . "<div class=\"fieldgroupField\">" . $this->fieldAddress->Field() . "</div>" . "</div>" . "</div>"; }
/** * @return string */ function Field($properties = array()) { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js'); Requirements::javascript('geoform/javascript/jquery.geocomplete.js'); if (GoogleMaps::getApiKey()) { Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang() . '&key=' . GoogleMaps::getApiKey()); } else { Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang()); } $name = $this->name; $js = <<<JS (function(\$){ \$(function(){ \t\t\$("#{$name}_Address").change(function(){ \t\t\t\$("#{$name}_Latitude").val(''); \$("#{$name}_Longditude").val(''); \t\t}); \$("#{$name}_Address").geocomplete().bind("geocode:result", function(event, result){ \$("#{$name}_Latitude").val(result.geometry.location.lat()); \$("#{$name}_Longditude").val(result.geometry.location.lng()); }); }); })(jQuery); JS; Requirements::customScript($js, 'GeoLocationField_Js_' . $this->ID()); $css = <<<CSS /* make the location suggest dropdown appear above dialog */ .pac-container { z-index: 2000 !important; } CSS; Requirements::customCSS($css, 'GeoLocationField_Css_' . $this->ID()); return "<div class=\"fieldgroup\">" . $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . "<div class=\"fieldgroupField\">" . $this->fieldAddress->Field() . "</div>" . "</div>"; }
public function Field($properties = array()) { $source = $this->getSource(); $options = array(); if ($source) { // SQLMap needs this to add an empty value to the options if (is_object($source) && $this->emptyString) { $options[] = new ArrayData(array('Value' => '', 'Title' => $this->emptyString)); } foreach ($source as $value => $params) { $selected = false; if ($value === '' && ($this->value === '' || $this->value === null)) { $selected = true; } else { // check against value, fallback to a type check comparison when !value if ($value) { $selected = $value == $this->value; } else { $selected = $value === $this->value || (string) $value === (string) $this->value; } $this->isSelected = $selected; } $disabled = false; if (in_array($value, $this->disabledItems) && $params['Title'] != $this->emptyString) { $disabled = 'disabled'; } $options[] = new ArrayData(array('Title' => $params['Title'], 'Value' => $value, 'Selected' => $selected, 'Disabled' => $disabled, 'Attributes' => $this->createOptionAttributes($params))); } } $properties = array_merge($properties, array('Options' => new ArrayList($options))); return FormField::Field($properties); }
/** * @param array $properties * @return string */ public function Field($properties = array()) { Requirements::css(CLOUDINARY_RELATIVE . "/css/CloudinaryColorSelectField.css"); Requirements::javascript(CLOUDINARY_RELATIVE . "/javascript/thirdparty/color-thief.js"); Requirements::javascript(CLOUDINARY_RELATIVE . "/javascript/CloudinaryColorSelectField.js"); return parent::Field($properties); }
public function Field($properties = array()) { // set the html js attributes $this->setAttribute('data-map-options', $this->getMapOptionsJS()); $this->setAttribute('data-draw-options', $this->getDrawOptionsJS()); // set the dependencies $this->requireDependencies(); return parent::Field($properties); }
/** * @param array $properties * * @return string */ public function Field($properties = array()) { if ($this->isReadonly()) { $nullableCheckbox = new CheckboxField_Readonly($this->getIsNullId()); } else { $nullableCheckbox = new CheckboxField($this->getIsNullId()); } $nullableCheckbox->setValue(is_null($this->dataValue())); return sprintf('%s %s <span>%s</span>', $this->valueField->Field(), $nullableCheckbox->Field(), $this->getIsNullLabel()); }
public function Field($properties = array()) { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(SS_FOCUS_AREA_DIR . '/thirdparty/jcrop/js/jquery.Jcrop.js'); Requirements::css(SS_FOCUS_AREA_DIR . '/thirdparty/jcrop/css/jquery.Jcrop.min.css'); Requirements::javascript(SS_FOCUS_AREA_DIR . '/javascript/mwm.focus-area.js'); Requirements::css(SS_FOCUS_AREA_DIR . '/css/mwm.focus-area.css'); return parent::Field($properties); }
/** * @param array $properties * @return HTMLText */ public function Field($properties = array()) { // Include a hidden field in the HTML if ($this->includeHiddenField && $this->readonly) { $hidden = clone $this; $hidden->setReadonly(false); return parent::Field($properties) . $hidden->Field($properties); } else { return parent::Field($properties); } }
public function Field($properties = array()) { $dir = basename(dirname(dirname(__DIR__))); Requirements::javascript($dir . '/javascript/MapField.js'); Requirements::css($dir . '/css/MapField.css'); $url = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=mapFieldInit'; if (Config::inst()->get('GoogleMap', 'api_key')) { $url .= '&key=' . Config::inst()->get('GoogleMap', 'api_key'); } Requirements::javascript($url, 'GoogleMaps'); return parent::Field($properties); }
/** * Adds in the requirements for the field * @param {array} $properties Array of properties for the form element (not used) * @return {string} Rendered field template */ public function Field($properties = array()) { $siteKey = self::config()->site_key; $secretKey = self::config()->secret_key; if (empty($siteKey) || empty($secretKey)) { user_error('You must configure Nocaptcha.site_key and Nocaptcha.secret_key, you can retrieve these at https://google.com/recaptcha', E_USER_ERROR); } Requirements::javascript(NOCAPTCHA_BASE . '/javascript/NocaptchaField.js'); Requirements::customScript("var _noCaptchaFields=_noCaptchaFields || [];_noCaptchaFields.push('" . $this->ID() . "');"); Requirements::customScript("(function() {\n" . " var gr = document.createElement('script'); gr.type = 'text/javascript'; gr.async = true;\n" . " gr.src = ('https:' == document.location.protocol ? 'https://www' : 'http://www') + " . "'.google.com/recaptcha/api.js?render=explicit&hl=" . i18n::get_lang_from_locale(i18n::get_locale()) . "&onload=noCaptchaFieldRender';\n" . " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gr, s);\n" . "})();\n", 'NocaptchaField-lib'); return parent::Field($properties); }
function Field($properties = array()) { $properties = array_merge( $properties, array( 'Name' => $this->action, 'Title' => ($this->description && !$this->useButtonTag) ? $this->description : $this->Title(), 'UseButtonTag' => $this->useButtonTag ) ); return parent::Field($properties); }
public function Field($properties = array()) { $config = SiteConfig::current_site_config(); $this->setAttribute('data-cloudname', $config->CloudName); $this->setAttribute('data-api', $config->APIKey); $this->setAttribute('data-preset', $config->UploadPreset); $this->setAttribute('data-url', $this->Link()); Requirements::javascript('cloudinary/javascript/thirdparty/jQuery-File-Upload-master/js/jquery.ui.widget.js'); Requirements::javascript('cloudinary/javascript/thirdparty/jQuery-File-Upload-master/js/jquery.iframe-transport.js'); Requirements::javascript('cloudinary/javascript/thirdparty/jQuery-File-Upload-master/js/jquery.fileupload.js'); Requirements::javascript('cloudinary/javascript/CloudinaryUpload.js'); Requirements::css('cloudinary/css/CloudinaryUpload.css'); return parent::Field($properties); }
public function Field($properties = array()) { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js'); $name = $this->getName(); // set caption if required $js = <<<JS !function(\$){ \$(function(){ // Try HTML5 geolocation if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position){ jQuery('#{$name}_Latitude').val(position.coords.latitude); jQuery('#{$name}_Longditude').val(position.coords.longitude); \t\t\t\t\tjQuery('#{$name}_PositionSet').val(1); }); } }); }(window.jQuery); JS; Requirements::customScript($js, 'HiddenLocationField_Js_' . $this->ID()); $field = $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . $this->fieldPositionSet->Field(); //SmallFieldHolder() return $field; }
public function Field() { $data = $this->form->getRecord(); if ($data->ID && is_numeric($data->ID)) { $idxField = $this->name . 'ID'; $hiddenField = "<input type=\"hidden\" id=\"" . $this->id() . "\" name=\"{$idxField}\" value=\"" . $this->attrValue() . "\" />"; $parentClass = $data->class; $parentID = $data->ID; $parentField = $this->name; $iframe = "<iframe name=\"{$this->name}_iframe\" src=\"{$this->controller}/iframe/{$parentClass}/{$parentID}/{$parentField}\" style=\"height: 202px; width: 600px; border-style: none;\"></iframe>"; return $iframe . $hiddenField; } else { $this->value = _t('FileIframeField.NOTEADDFILES', 'You can add files once you have saved for the first time.'); return FormField::Field(); } }
public function Field($properties = array()) { Requirements::customScript(<<<JS \t\t\t(function(\$) { \t\t\t\tvar edit_form_id = "Form_EditForm"; \t\t\t\tvar alt_edit_form_id = "Form_ItemEditForm"; \t\t\t\t\$.entwine('ss', function(\$){ \t\t\t\t\t\$('.cms-edit-form input#Form_EditForm_{$this->getName()}').entwine({ \t\t\t\t\t\t// Constructor: onmatch \t\t\t\t\t\tonmatch : function() { \t\t\t\t\t\t\tif (!\$("#" + edit_form_id ).length) { \t\t\t\t\t\t\t\tedit_form_id = alt_edit_form_id; \t\t\t\t\t\t\t} \t\t\t\t\t\t\tconsole.log("#" + edit_form_id + "_{$this->getName()}"); \t\t\t\t\t\t\t\$( "#" + edit_form_id + "_{$this->getName()}" ).autocomplete({ \t\t\t\t\t\t\t\tsource: function( request, response ) { \t\t\t\t\t\t\t\t\t\$.ajax({ \t\t\t\t\t\t\t\t\t url: "//suggestqueries.google.com/complete/search", \t\t\t\t\t\t\t\t\t dataType: "jsonp", \t\t\t\t\t\t\t\t\t data: { \t\t\t\t\t\t\t\t\t\t client: 'firefox', \t\t\t\t\t\t\t\t\t q: request.term \t\t\t\t\t\t\t\t\t }, \t\t\t\t\t\t\t\t\t success: function( data ) { \t\t\t\t\t\t\t\t\t response( data[1] ); \t\t\t\t\t\t\t\t\t } \t\t\t\t\t\t\t\t\t}); \t\t\t\t\t\t\t\t}, \t\t\t\t\t\t\t\tminLength: 3 \t\t\t\t\t\t\t}); \t \t\t\t\t\t\t}, \t\t\t\t\t}); \t\t\t\t}); \t\t\t})(jQuery); JS ); $this->addExtraClass('text'); return parent::Field($properties); }
public function Field($properties = array()) { $image = $this->getImage(); if (!$image) { return false; } FormExtraJquery::include_jquery(); if (self::config()->use_hammer) { FormExtraJquery::include_hammer(); } if (self::config()->use_mousewheel) { FormExtraJquery::include_mousewheel(); } Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/cropbox/jquery.cropbox.js'); Requirements::css(FORM_EXTRAS_PATH . '/javascript/cropbox/jquery.cropbox.css'); Requirements::customScript("jQuery( '.cropbox-field' ).each( function () {\n\t\t\tvar t = jQuery(this),\n\t\t\timage = t.find('img'),\n cropwidth = image.data('cropwidth'),\n cropheight = image.data('cropheight'),\n\t\t\tx = jQuery('[name=CropX]', t),\n y = jQuery('[name=CropY]', t),\n w = jQuery('[name=CropWidth]', t),\n h = jQuery('[name=CropHeight]', t)\n\t\t;\n\n image.cropbox( {width: cropwidth, height: cropheight, result: {cropX:x.val(), cropY:y.val(), cropW:w.val(), cropH:h.val()} })\n .on('cropbox', function( event, results, img ) {\n\t\t\t\tx.val(results.cropX);\n\t\t\t\ty.val(results.cropY);\n\t\t\t\tw.val(results.cropW);\n\t\t\t\th.val(results.cropH);\n })\n\t\t\t;\n } );", 'cropboxFieldInit'); return parent::Field($properties); }
public function Field($properties = array()) { $dirName = basename(dirname(dirname(__FILE__))); Requirements::javascript($dirName . '/javascript/Polyfill.js'); Requirements::javascript($dirName . '/javascript/ImageSelect.jquery.js'); Requirements::css($dirName . '/css/ImageSelect.css'); $source = $this->getSource(); $options = array(); if ($source) { if (is_object($source) && $this->hasEmptyDefault) { $options[] = new ArrayData(array('Value' => '', 'Title' => $this->emptyString, 'Image' => '')); } foreach ($source as $item) { $value = $item->{$this->keyField}; if (empty($this->labelField)) { $title = '--nbsp'; } else { $title = $item->{$this->labelField}; } $image = $item->{$this->imageField}(); $selected = false; if ($value === '' && ($this->value === '' || $this->value === null)) { $selected = true; } else { // check against value, fallback to a type check comparison when !value if ($value) { $selected = $value == $this->value; } else { $selected = $value === $this->value || (string) $value === (string) $this->value; } $this->isSelected = $selected; } $disabled = false; if (in_array($value, $this->disabledItems) && $title != $this->emptyString) { $disabled = 'disabled'; } $options[] = new ArrayData(array('Title' => $title, 'Value' => $value, 'Image' => $image, 'Selected' => $selected, 'Disabled' => $disabled)); } } $properties = array_merge($properties, array('Options' => new ArrayList($options))); return FormField::Field($properties); }
/** * {@inheritdoc} */ public function Field($properties = array()) { $source = $this->getSource(); $odd = 0; $options = array(); if ($source) { foreach ($source as $value => $title) { // Ensure $title is safely cast if (!$title instanceof DBField) { $title = DBField::create_field('Text', $title); } $itemID = $this->ID() . '_' . preg_replace('/[^a-zA-Z0-9]/', '', $value); $odd = ($odd + 1) % 2; $extraClass = $odd ? 'odd' : 'even'; $extraClass .= ' val' . preg_replace('/[^a-zA-Z0-9\\-\\_]/', '_', $value); $options[] = new ArrayData(array('ID' => $itemID, 'Class' => $extraClass, 'Name' => $this->name, 'Value' => $value, 'Title' => $title, 'isChecked' => $value == $this->value, 'isDisabled' => $this->disabled || in_array($value, $this->disabledItems))); } } $properties = array_merge($properties, array('Options' => new ArrayList($options))); return FormField::Field($properties); }
public function Field($id = null) { $data = $this->form->getRecord(); if ($id && is_numeric($id)) { $parentID = $id; } elseif ($data) { $parentID = $data->ID; } else { $parentID = null; } if ($data && $parentID && is_numeric($parentID)) { $idxField = $this->name . 'ID'; $hiddenField = "<input class=\"hidden\" type=\"hidden\" id=\"" . $this->id() . "\" name=\"{$idxField}\" value=\"" . $this->attrValue() . "\" />"; $parentClass = $data->class; $parentField = $this->name; $iframe = "<iframe name=\"{$this->name}_iframe\" src=\"images/iframe/{$parentClass}/{$parentID}/{$parentField}\" style=\"height: 152px; width: 525px; border: none;\" frameborder=\"0\"></iframe>"; return $iframe . $hiddenField; } else { $this->value = _t('ImageField.NOTEADDIMAGES', 'You can add images once you have saved for the first time.'); return FormField::Field(); } }
/** * @return HTMLText */ public function Field($properties = array()) { Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/javascript/lang'); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jstree/jquery.jstree.js'); Requirements::javascript(FRAMEWORK_DIR . '/javascript/TreeDropdownField.js'); Requirements::css(FRAMEWORK_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::css(FRAMEWORK_DIR . '/css/TreeDropdownField.css'); if ($this->showSearch) { $emptyTitle = _t('DropdownField.CHOOSESEARCH', '(Choose or Search)', 'start value of a dropdown'); } else { $emptyTitle = _t('DropdownField.CHOOSE', '(Choose)', 'start value of a dropdown'); } $record = $this->Value() ? $this->objectForKey($this->Value()) : null; if ($record instanceof ViewableData) { $title = $record->obj($this->labelField)->forTemplate(); } elseif ($record) { $title = Convert::raw2xml($record->{$this->labelField}); } else { $title = $emptyTitle; } // TODO Implement for TreeMultiSelectField $metadata = array('id' => $record ? $record->ID : null, 'ClassName' => $record ? $record->ClassName : $this->sourceObject); $properties = array_merge($properties, array('Title' => $title, 'EmptyTitle' => $emptyTitle, 'Metadata' => $metadata ? Convert::raw2json($metadata) : null)); return parent::Field($properties); }
public function Field($properties = array()) { $properties = array_merge($properties, array('MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize())); return parent::Field($properties); }
/** * @param array $properties * @see https://developers.google.com/maps/documentation/javascript/reference * {@inheritdoc} */ public function Field($properties = array()) { $jsOptions = array('coords' => array($this->recordFieldData('Latitude'), $this->recordFieldData('Longitude')), 'map' => array('zoom' => $this->recordFieldData('Zoom') ?: $this->getOption('map.zoom'), 'mapTypeId' => 'ROADMAP')); $jsOptions = array_replace_recursive($this->options, $jsOptions); $this->setAttribute('data-settings', Convert::array2json($jsOptions)); $this->requireDependencies(); return parent::Field($properties); }
public function Field($properties = array()) { Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js'); if (GoogleMaps::getApiKey()) { Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang() . '&key=' . GoogleMaps::getApiKey()); } else { Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang()); } $name = $this->getName(); $postcode = _t('PostCodeLocationField.ZIPCODEPLACEHOLDER', 'ZIP/Postcode'); $country = _t('PostCodeLocationField.CITYCOUNTRYPLACEHOLDER', 'City/Country'); // set caption if required $js = <<<JS jQuery(document).ready(function() { // bind PostCodeLocationChanged to Postcode and Country Fields jQuery('#{$name}_Postcode').keyup({$name}PostCodeLocationChanged).focus({$name}PostCodeLocationEmptyPostcode); jQuery('#{$name}_Country').keyup({$name}PostCodeLocationChanged).focus({$name}PostCodeLocationEmptyCountry); // alternatively there exists a jquery Plugin JQUERY-TYPING }); function {$name}PostCodeLocationEmptyPostcode(){ if(jQuery('#{$name}_Postcode').val().indexOf('{$postcode}') > -1){ jQuery('#{$name}_Postcode').val(''); } } function {$name}PostCodeLocationEmptyCountry(){ if(jQuery('#{$name}_Country').val().indexOf('{$country}') > -1){ jQuery('#{$name}_Country').val(''); } } var {$name}PostcodeTypeTimer = null; // react on typing function {$name}PostCodeLocationChanged(){ // check typeTimer and delete if({$name}PostcodeTypeTimer){ clearTimeout({$name}PostcodeTypeTimer); } // trim Postcode value var postcode = jQuery('#{$name}_Postcode').val().replace(/\\s+\$/,"").replace(/^\\s+/,""); // trim Country value var country = jQuery('#{$name}_Country').val().replace(/\\s+\$/,"").replace(/^\\s+/,""); // Postcode or Country at least more than 2 digits and not placeholster is stristr of value if(((postcode.length >= 2 && !("{$postcode}".indexOf(postcode) > -1)) || country.length >= 2 && !("{$country}".indexOf(country) > -1)) && !("{$postcode}".indexOf(postcode) > -1 && "{$country}".indexOf(country) > -1)){ {$name}PostcodeTypeTimer = setTimeout('{$name}PostCodeLocationFetch()', 500); // execute googlemaps request after 1/2 second of not typing } } var {$name}PostcodeGeocoder = null; // fetch google data and update lat, lng function {$name}PostCodeLocationFetch(){ // clear Lat + Lng jQuery('#{$name}_Latitude').val(''); jQuery('#{$name}_Longditude').val(''); // trim Postcode value var postcode = jQuery('#{$name}_Postcode').val().replace(/\\s+\$/,"").replace(/^\\s+/,""); // trim Country value var country = jQuery('#{$name}_Country').val().replace(/\\s+\$/,"").replace(/^\\s+/,""); postcode = ("{$postcode}".indexOf(postcode) == -1) ? postcode : ''; country = ("{$country}".indexOf(country) == -1) ? country : ''; // create request var Request = { address: postcode+', '+country }; // create geocoder {$name}PostcodeGeocoder = new google.maps.Geocoder(); {$name}PostcodeGeocoder.geocode(Request, {$name}PostcodeGeocoderCallback); } function {$name}PostcodeGeocoderCallback(Response, Status){ // Status OK if(Status == 'OK'){ if(Response.length == 1){ jQuery('#{$name}_Latitude').val(Response[0]['geometry']['location'].lat()); jQuery('#{$name}_Longditude').val(Response[0]['geometry']['location'].lng()); //alert(\$('#{$name}_Latitude').val()+','+\$('#{$name}_Longditude').val()); }else{ // check if there is only one locality, while all others are places of interest var id = PostcodeIsSingleLocality(Response); if(id != null){ jQuery('#{$name}_Latitude').val(Response[id]['geometry']['location'].lat()); jQuery('#{$name}_Longditude').val(Response[id]['geometry']['location'].lng()); } // else result not unique //alert(Response.length); } } } function PostcodeIsSingleLocality(Response){ // check if Response has only one locality->Political var counter = 0; var locality = null; for(var i=0; i<Response.length; i++){ // check if type is locality political if(Response[i]['types'][0] == 'locality' && Response[i]['types'][1] == 'political'){ locality = i; counter++; } } return (counter == 1) ? locality : null; } JS; Requirements::customScript($js, 'PostCodeLocationField_Js_' . $this->ID()); if ($this->wrapFieldgroup) { $field = "<div class=\"fieldgroup\">" . $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . "<div class=\"fieldgroup-field\">" . $this->fieldPostcode->Field() . " " . $this->fieldCountry->Field() . "</div>" . "</div>"; } else { $field = $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . $this->fieldPostcode->Field() . " " . $this->fieldCountry->Field(); } return $field; }
public function Field($properties = array()) { Requirements::javascript('silverstripe-postmarked/javascript/ObjectSelectorField.js'); Requirements::css('silverstripe-postmarked/css/ObjectSelectorField.css'); return parent::Field($properties); }
/** * @param array $properties * @return string */ public function Field($properties = array()) { Requirements::css(FRAMEWORK_DIR . '/client/dist/styles/DatetimeField.css'); return parent::Field($properties); }
function Field($properties = array()) { $source = $this->getSource(); $options = array(); if($source) { // SQLMap needs this to add an empty value to the options if(is_object($source) && $this->emptyString) { $options[] = new ArrayData(array( 'Value' => '', 'Title' => $this->emptyString, )); } foreach($source as $value => $title) { $selected = false; if($value === '' && ($this->value === '' || $this->value === null)) { $selected = true; } else { // check against value, fallback to a type check comparison when !value $selected = ($value) ? $value == $this->value : $value === $this->value; $this->isSelected = $selected; } $options[] = new ArrayData(array( 'Title' => $title, 'Value' => $value, 'Selected' => $selected, )); } } $properties = array_merge($properties, array('Options' => new ArrayList($options))); return parent::Field($properties); }
/** * @param array $properties * @return HTMLText */ public function Field($properties = array()) { $source = $this->getSource(); $options = array(); if ($this->getHasEmptyDefault()) { $selected = $this->value === '' || $this->value === null; $disabled = in_array('', $this->disabledItems, true) ? 'disabled' : false; $options[] = new ArrayData(array('Value' => '', 'Title' => $this->getEmptyString(), 'Selected' => $selected, 'Disabled' => $disabled)); } if ($source) { foreach ($source as $value => $title) { $selected = false; if ($value === '' && ($this->value === '' || $this->value === null)) { $selected = true; } else { // check against value, fallback to a type check comparison when !value if ($value) { $selected = $value == $this->value; } else { $selected = $value === $this->value || (string) $value === (string) $this->value; } $this->isSelected = $selected; } $disabled = false; if (in_array($value, $this->disabledItems) && $title != $this->emptyString) { $disabled = 'disabled'; } $options[] = new ArrayData(array('Title' => $title, 'Value' => $value, 'Selected' => $selected, 'Disabled' => $disabled)); } } $properties = array_merge($properties, array('Options' => new ArrayList($options))); return parent::Field($properties); }
/** * Returns a <select> tag containing all the appropriate <option> tags */ public function Field($properties = array()) { if ($this->multiple) { $this->name .= '[]'; } $options = array(); // We have an array of values if (is_array($this->value)) { // Loop through and figure out which values were selected. foreach ($this->getSource() as $value => $title) { $options[] = new ArrayData(array('Title' => $title, 'Value' => $value, 'Selected' => in_array($value, $this->value) || in_array($value, $this->defaultItems), 'Disabled' => $this->disabled || in_array($value, $this->disabledItems))); } } else { // Listbox was based a singlular value, so treat it like a dropdown. foreach ($this->getSource() as $value => $title) { $options[] = new ArrayData(array('Title' => $title, 'Value' => $value, 'Selected' => $value == $this->value || in_array($value, $this->defaultItems), 'Disabled' => $this->disabled || in_array($value, $this->disabledItems))); } } $properties = array_merge($properties, array('Options' => new ArrayList($options))); return FormField::Field($properties); }