本文整理汇总了PHP中ListboxField::Field方法的典型用法代码示例。如果您正苦于以下问题:PHP ListboxField::Field方法的具体用法?PHP ListboxField::Field怎么用?PHP ListboxField::Field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListboxField
的用法示例。
在下文中一共展示了ListboxField::Field方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Field
public function Field($properties = array())
{
Requirements::javascript(BOLTTOOLS_DIR . '/javascript/addnewlistboxfield.js');
$this->setTemplate('AddNewListboxField');
$this->addExtraClass('has-chzn');
return parent::Field($properties);
}
示例2: Field
public function Field($properties = array())
{
FormExtraJquery::include_jquery();
// Use updated version of Chosen
Requirements::block(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.css');
Requirements::block(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js');
Requirements::css(FORM_EXTRAS_PATH . '/javascript/chosen/chosen.min.css');
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/chosen/chosen.jquery.js');
if ($this->use_order) {
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/chosen_order/chosen.order.jquery.js');
}
// Init
$opts = array('no_results_text' => $this->no_results_text, 'allow_single_deselect' => $this->allow_single_deselect ? true : false);
if (self::config()->rtl) {
$this->addExtraClass('chosen-rtl');
}
if ($this->allow_max_selected) {
$opts['allow_max_selected'] = $this->allow_max_selected;
}
if ($this->use_order) {
$stringValue = $this->value;
if (is_array($stringValue)) {
$stringValue = implode(',', $stringValue);
}
$this->setAttribute('data-chosen-order', $stringValue);
}
$this->setAttribute('data-chosen', json_encode($opts));
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/ChosenField.js');
return parent::Field($properties);
}
示例3: 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;
}
示例4: Field
public function Field($properties = array())
{
FormExtraJquery::include_jquery();
$use_v3 = self::config()->use_v3;
if ($use_v3) {
Requirements::css(FORM_EXTRAS_PATH . '/javascript/select2-v3/select2.css');
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/select2-v3/select2.min.js');
// Locale support
$lang = i18n::get_lang_from_locale(i18n::get_locale());
if ($lang != 'en') {
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/select2-v3/select2_locale_' . $lang . '.js');
}
} else {
// Locale support
$lang = i18n::get_lang_from_locale(i18n::get_locale());
if ($lang != 'en') {
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/select2-v4/i18n/' . $lang . '.js');
}
// Use full release
Requirements::css(FORM_EXTRAS_PATH . '/javascript/select2-v4/css/select2.min.css');
FormExtraJquery::include_mousewheel();
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/select2-v4/js/select2.full.min.js');
}
// Build options
$opts = array();
if ($this->allow_single_deselect) {
if ($use_v3) {
$opts['allowClear'] = $this->allow_single_deselect;
} else {
$opts['allow_clear'] = $this->allow_single_deselect;
}
}
if ($this->allow_max_selected) {
if ($use_v3) {
$opts['maximumSelectionSize'] = $this->allow_max_selected;
} else {
$opts['maximumSelectionLength'] = $this->allow_max_selected;
}
}
if ($this->tags) {
if ($use_v3) {
if (is_array($this->source)) {
$source = array_values($this->source);
} else {
$source = array();
}
// Tags is an array
$opts['tags'] = $source;
$opts['tokenSeparators'] = $this->token_separators;
// Not compatible with select
$this->multiple = false;
$this->template = 'HiddenField';
} else {
// Tags are calculated from options
$opts['tags'] = $this->tags;
$opts['token_separators'] = $this->token_separators;
$opts['free_order'] = $this->free_order;
}
}
if (self::config()->rtl && !$use_v3) {
$opts['dir'] = 'rtl';
}
if ($this->ajax) {
$opts['ajax'] = $this->ajax;
}
if (FormExtraJquery::isAdminBackend()) {
Requirements::customScript('var select2_' . $this->ID() . ' = ' . json_encode($opts));
Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/Select2Field.js');
} else {
Requirements::customScript('jQuery("#' . $this->ID() . '").select2(' . json_encode($opts) . ');');
}
if ($use_v3) {
// If you need to adjust the size, it's better to use the field container instead
$this->setAttribute('style', 'width:100%');
}
return parent::Field($properties);
}
示例5: testFieldRenderingMultipleOn
public function testFieldRenderingMultipleOn()
{
$choices = array('a' => 'a value', 'b' => 'b value', 'c' => 'c value');
$field = new ListboxField('Choices', 'Choices', $choices);
$field->multiple = true;
$field->setValue('a,c');
$parser = new CSSContentParser($field->Field());
$optEls = $parser->getBySelector('option');
$this->assertEquals(3, count($optEls));
$this->assertEquals('selected', (string) $optEls[0]['selected']);
$this->assertEquals('', (string) $optEls[1]['selected']);
$this->assertEquals('selected', (string) $optEls[2]['selected']);
}
示例6: Field
/**
* @param array $properties
* @return HTMLText
*/
public function Field($properties = array())
{
Requirements::css(MULTISELECT_BASE . '/thirdparty/multiselect/css/ui.multiselect.css');
Requirements::css(MULTISELECT_BASE . '/css/MultiSelectField.css');
Requirements::javascript(MULTISELECT_BASE . '/thirdparty/multiselect/js/ui.multiselect.js');
Requirements::javascript(MULTISELECT_BASE . '/javascript/MultiSelectField.js');
return parent::Field($properties);
}
开发者ID:helpfulrobot,项目名称:fullscreeninteractive-silverstripe-multiselectfield,代码行数:12,代码来源:MultiSelectField.php