当前位置: 首页>>代码示例>>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;未经允许,请勿转载。