當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DropdownField::Field方法代碼示例

本文整理匯總了PHP中DropdownField::Field方法的典型用法代碼示例。如果您正苦於以下問題:PHP DropdownField::Field方法的具體用法?PHP DropdownField::Field怎麽用?PHP DropdownField::Field使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DropdownField的用法示例。


在下文中一共展示了DropdownField::Field方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAddExtraClass

	function testAddExtraClass() {
		/* DropdownField has an extra class name and is in the HTML the field returns */
		$dropdownField = new DropdownField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes'), '', null, '(Select one)');
		$dropdownField->addExtraClass('thisIsMyExtraClassForDropdownField');
		preg_match('/thisIsMyExtraClassForDropdownField/', $dropdownField->Field(), $matches);
		$this->assertTrue($matches[0] == 'thisIsMyExtraClassForDropdownField');
	}
開發者ID:neopba,項目名稱:silverstripe-book,代碼行數:7,代碼來源:DropdownFieldTest.php

示例2: Field

 public function Field($properties = array())
 {
     if (empty($this->source) || count($this->source) === 1) {
         $this->setEmptyString('');
     }
     return parent::Field($properties);
 }
開發者ID:helpfulrobot,項目名稱:lekoala-silverstripe-form-extras,代碼行數:7,代碼來源:ComboField.php

示例3: testReadonlyField

	function testReadonlyField() {
		$dropdownField = new DropdownField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes'), '', null, '(Select one)');
		$dropdownField->setValue(1);
		$readonlyDropdownField = $dropdownField->performReadonlyTransformation();
		preg_match('/Yes/', $dropdownField->Field(), $matches);
		$this->assertEquals($matches[0], 'Yes');
	}
開發者ID:redema,項目名稱:sapphire,代碼行數:7,代碼來源:DropdownFieldTest.php

示例4: Field

 function Field()
 {
     $source = $this->getSource();
     if ($this->defaultToVisitorCountry && !$this->value || !isset($source[$this->value])) {
         $this->value = ($vc = Geoip::visitor_country()) ? $vc : Geoip::$default_country_code;
     }
     return parent::Field();
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:8,代碼來源:CountryDropdownField.php

示例5: testStringOneValueSelectedOptionBehaviour

 public function testStringOneValueSelectedOptionBehaviour()
 {
     $field = new DropdownField('Field', null, array('-1' => 'some negative', '0' => 'none', '1' => 'one', '2+' => 'two or more'), '1');
     $selectedOptions = $this->findSelectedOptionElements($field->Field());
     $this->assertEquals((string) $selectedOptions[0], 'one', 'The selected option is "one"');
     $field = new DropdownField('Field', null, array('-1' => 'some negative', '0' => 'none', '1' => 'one', '2+' => 'two or more'), 1);
     $selectedOptions = $this->findSelectedOptionElements($field->Field());
     $this->assertEquals((string) $selectedOptions[0], 'one', 'The selected option is "one"');
 }
開發者ID:jakedaleweb,項目名稱:AtomCodeChallenge,代碼行數:9,代碼來源:DropdownFieldTest.php

示例6: getColumnContent

 /**
  * {@inheritdoc}
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if ($columnName === 'MergeAction' && $record->{$this->childMethod}()->Count() > 0) {
         $dropdown = new DropdownField('Target', 'Target', $this->records->exclude('ID', $record->ID)->map());
         $prefix = strtolower($this->parentMethod . '-' . $this->childMethod);
         $action = GridFieldFormAction::create($gridField, 'MergeAction' . $record->ID, 'Move', 'merge', array('record' => $record->ID, 'target' => $prefix . '-target-record-' . $record->ID));
         $action->setExtraAttributes(array('data-target' => $prefix . '-target-record-' . $record->ID));
         return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>';
     }
     return null;
 }
開發者ID:unclecheese,項目名稱:silverstripe-blog,代碼行數:14,代碼來源:GridFieldMergeAction.php

示例7: Field

 /**
  * @param array $properties
  * @return HTMLText
  */
 public function Field($properties = array())
 {
     $this->addExtraClass('selectboxfield')->setAttribute('data-selectboxconfig', Convert::array2json($this->selectbox_config));
     //allow for not including default styles
     if ($this->config()->get('require_css') == true) {
         Requirements::css(SELECTBOX_DROPDOWN_FIELD_DIR_THIRD_PARTY_DIR . 'jquery.selectbox-0.2/css/jquery.selectbox.css');
     }
     Requirements::javascript(SELECTBOX_DROPDOWN_FIELD_DIR_THIRD_PARTY_DIR . 'jquery.selectbox-0.2/js/jquery.selectbox-0.2.min.js');
     Requirements::javascript(SELECTBOX_DROPDOWN_FIELD_JAVASCRIPT . '/selectbox.dropdown.field.js');
     return parent::Field($properties);
 }
開發者ID:muskie9,項目名稱:silverstripe-selectboxfield,代碼行數:15,代碼來源:SelectboxDropdownField.php

示例8: Field

 public function Field($properties = array())
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(DEPENDENTDROPDOWNFIELD . '/javascript/dependentdropdownfield.js');
     $this->setAttribute('data-link', $this->Link('load'));
     $this->setAttribute('data-depends', $this->getDepends()->getName());
     $this->setAttribute('data-empty', $this->getEmptyString());
     $this->setAttribute('data-unselected', $this->getUnselectedString());
     return parent::Field($properties);
 }
開發者ID:helpfulrobot,項目名稱:sheadawson-silverstripe-dependentdropdownfield,代碼行數:11,代碼來源:DependentDropdownField.php

示例9: Field

 public function Field($properties = array())
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(SELECT2_MODULE . "/select2/select2.js");
     Requirements::javascript(SELECT2_MODULE . "/javascript/select2.init.js");
     Requirements::css(SELECT2_MODULE . "/select2/select2.min.css");
     $this->addExtraClass('select2')->addExtraClass('no-chzn');
     if (!$this->getAttribute('data-search-threshold')) {
         $this->setSearchThreshold(self::$default_search_threshold);
     }
     return parent::Field($properties);
 }
開發者ID:sheadawson,項目名稱:silverstripe-select2,代碼行數:13,代碼來源:Select2Field.php

示例10: Field

 public function Field($properties = array())
 {
     $this->addExtraClass('ColorpaletteInput');
     ColorpaletteHelper::requirements();
     Requirements::javascript("calendar/javascript/admin/ColorpaletteField.js");
     $source = $this->getSource();
     //adding the current value to the mix if isn't in the array
     $val = $this->getColorWithHash();
     $this->value = $val;
     $source[$val] = $val;
     $this->setSource($source);
     return parent::Field();
 }
開發者ID:andrewandante,項目名稱:silverstripe-calendar,代碼行數:13,代碼來源:ColorpaletteField.php

示例11: Field

 public function Field($properties = array())
 {
     $source = $this->getSource();
     if (!$this->value || !isset($source[$this->value])) {
         if ($this->config()->get('default_to_locale') && $this->locale()) {
             $locale = new Zend_Locale();
             $locale->setLocale($this->locale());
             $this->value = $locale->getRegion();
         }
     }
     if (!$this->value || !isset($source[$this->value])) {
         $this->value = $this->config()->get('default_country');
     }
     return parent::Field();
 }
開發者ID:normann,項目名稱:sapphire,代碼行數:15,代碼來源:CountryDropdownField.php

示例12: Field

 public function Field($properties = array())
 {
     $source = $this->getSource();
     // Default value to best availabel locale
     $value = $this->Value();
     if ($this->config()->default_to_locale && (!$value || !isset($source[$value])) && $this->locale()) {
         $locale = new Zend_Locale();
         $locale->setLocale($this->locale());
         $value = $locale->getRegion();
         $this->setValue($value);
     }
     // Default to default country otherwise
     if (!$value || !isset($source[$value])) {
         $this->setValue($this->config()->default_country);
     }
     return parent::Field($properties);
 }
開發者ID:jacobbuck,項目名稱:silverstripe-framework,代碼行數:17,代碼來源:CountryDropdownField.php

示例13: Field

 /**
  * Returns a readonly span containing the correct value.
  *
  * @param array $properties
  *
  * @return string
  */
 public function Field($properties = array())
 {
     $source = $this->getSource();
     // Normalize value to array to simplify further processing
     if (is_array($this->value) || is_object($this->value)) {
         $values = $this->value;
     } else {
         $values = array(trim($this->value));
     }
     $mapped = array();
     if ($source instanceof SQLMap) {
         foreach ($values as $value) {
             $mapped[] = $source->getItem($value);
         }
     } else {
         if ($source instanceof ArrayAccess || is_array($source)) {
             $source = ArrayLib::flatten($source);
             foreach ($values as $value) {
                 if (isset($source[$value])) {
                     $mapped[] = $source[$value];
                 }
             }
         } else {
             $mapped = array();
         }
     }
     // Don't check if string arguments are matching against the source,
     // as they might be generated HTML diff views instead of the actual values
     if ($this->value && !is_array($this->value) && !$mapped) {
         $mapped = array(trim($this->value));
         $values = array();
     }
     if ($mapped) {
         $attrValue = implode(', ', array_values($mapped));
         if (!$this->dontEscape) {
             $attrValue = Convert::raw2xml($attrValue);
         }
         $inputValue = implode(', ', array_values($values));
     } else {
         $attrValue = "<i>(none)</i>";
         $inputValue = '';
     }
     $properties = array_merge($properties, array('AttrValue' => $attrValue, 'InputValue' => $inputValue));
     return parent::Field($properties);
 }
開發者ID:congaaids,項目名稱:silverstripe-framework,代碼行數:52,代碼來源:LookupField.php

示例14: Field

    /**
     * @param array $parameters
     * @return string
     */
    public function Field($parameters = array())
    {
        $field = parent::Field($parameters);
        if ($this->autocomplete) {
            $this->addExtraClass("chosenAutocompleteField");
            $field = parent::Field($parameters);
            Requirements::css("dropdown2autocomplete/javascript/chosen/chosen.min.css");
            Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
            Requirements::javascript("dropdown2autocomplete/javascript/chosen/chosen.jquery.min.js");
            Requirements::customScript('
					jQuery("#' . $this->ID() . '").chosen(' . $this->Config()->get("js_settings") . ');
					jQuery("body").on(
						"focus",
						".chosenAutocompleteField:visible",
						function(){
							jQuery(this).chosen(' . $this->Config()->get("js_settings") . ');
						}
					);
				', $this->ID() . "_chosen_setup");
        }
        return $field;
    }
開發者ID:sunnysideup,項目名稱:dropdown2autocomplete,代碼行數:26,代碼來源:GroupedDropdown2AutocompleteField.php

示例15: Field

 /**
  * @todo This should be generated by JavaScript, but we don't have the date libraries'
  */
 function Field($properties = array())
 {
     $this->addExtraClass('timedropdownfield');
     $html = parent::Field($properties);
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript('timedropdownfield/javascript/TimeDropdownField.js');
     Requirements::css('timedropdownfield/css/TimeDropdownField.css');
     $iteratedTime = new Zend_Date('00:00:00', 'h:mm:ss');
     $options = array();
     $count = 24 * (60 / $this->config['interval']);
     for ($i = 0; $i < $count; $i++) {
         $key = $iteratedTime->toString($this->getConfig('datavalueformat'));
         $options[$key] = $iteratedTime->toString($this->getConfig('timeformat'));
         $iteratedTime->add($this->config['interval'], Zend_Date::MINUTE);
     }
     $dropdownField = new DropdownField('dropdown_' . $this->getName(), false, $options, $this->Value());
     $dropdownField->addExtraClass('presets');
     $dropdownField->setHasEmptyDefault(true);
     $dropdownField->setForm($this->getForm());
     $html .= $dropdownField->Field();
     $html .= '<a href="#" class="presets-trigger"></a>';
     return $html;
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-timedropdownfield,代碼行數:27,代碼來源:TimeDropdownField.php


注:本文中的DropdownField::Field方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。