当前位置: 首页>>代码示例>>PHP>>正文


PHP OptionsetField::setValue方法代码示例

本文整理汇总了PHP中OptionsetField::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsetField::setValue方法的具体用法?PHP OptionsetField::setValue怎么用?PHP OptionsetField::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OptionsetField的用法示例。


在下文中一共展示了OptionsetField::setValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ConvertObjectForm

 /**
  * Form used for defining the conversion form
  * @return {Form} Form to be used for configuring the conversion
  */
 public function ConvertObjectForm()
 {
     //Reset the reading stage
     Versioned::reset();
     $fields = new FieldList(CompositeField::create($convertModeField = new OptionsetField('ConvertMode', '', array('ReplacePage' => _t('KapostAdmin.REPLACES_AN_EXISTING_PAGE', '_This replaces an existing page'), 'NewPage' => _t('KapostAdmin.IS_NEW_PAGE', '_This is a new page')), 'NewPage'))->addExtraClass('kapostConvertLeftSide'), CompositeField::create($replacePageField = TreeDropdownField::create('ReplacePageID', _t('KapostAdmin.REPLACE_PAGE', '_Replace this page'), 'SiteTree')->addExtraClass('replace-page-id'), TreeDropdownField::create('ParentPageID', _t('KapostAdmin.USE_AS_PARENT', '_Use this page as the parent for the new page, leave empty for a top level page'), 'SiteTree')->addExtraClass('parent-page-id'))->addExtraClass('kapostConvertRightSide'));
     $actions = new FieldList(FormAction::create('doConvertObject', _t('KapostAdmin.CONTINUE_CONVERT', '_Continue'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'kapost-convert'));
     $validator = new RequiredFields('ConvertMode');
     $form = new Form($this, 'ConvertObjectForm', $fields, $actions, $validator);
     $form->addExtraClass('KapostAdmin center')->setAttribute('data-layout-type', 'border')->setTemplate('KapostAdmin_ConvertForm');
     //Handle pages to see if the page exists
     $convertToClass = $this->getDestinationClass();
     if ($convertToClass !== false && ($convertToClass == 'SiteTree' || is_subclass_of($convertToClass, 'SiteTree'))) {
         $obj = SiteTree::get()->filter('KapostRefID', Convert::raw2sql($this->record->KapostRefID))->first();
         if (!empty($obj) && $obj !== false && $obj->ID > 0) {
             $convertModeField->setValue('ReplacePage');
             $replacePageField->setValue($obj->ID);
             $recordTitle = $this->record->Title;
             if (!empty($recordTitle) && $recordTitle != $obj->Title) {
                 $urlFieldLabel = _t('KapostAdmin.TITLE_CHANGE_DETECT', '_The title differs from the page being replaced, it was "{wastitle}" and will be changed to "{newtitle}". Do you want to update the URL Segment?', array('wastitle' => $obj->Title, 'newtitle' => $recordTitle));
                 $fields->push(CheckboxField::create('UpdateURLSegment', $urlFieldLabel)->addExtraClass('urlsegmentcheck')->setAttribute('data-replace-id', $obj->ID)->setForm($form)->setDescription(_t('KapostAdmin.NEW_URL_SEGMENT', '_The new URL Segment will be or will be close to "{newsegment}"', array('newsegment' => $obj->generateURLSegment($recordTitle)))));
             }
         }
     }
     Requirements::css(KAPOST_DIR . '/css/KapostAdmin.css');
     Requirements::add_i18n_javascript(KAPOST_DIR . '/javascript/lang/');
     Requirements::javascript(KAPOST_DIR . '/javascript/KapostAdmin_convertPopup.js');
     //Allow extensions to adjust the form
     $this->extend('updateConvertObjectForm', $form, $this->record);
     return $form;
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-kapost-bridge,代码行数:34,代码来源:KapostGridFieldDetailForm_ItemRequest.php

示例2: setValue

 function setValue($value)
 {
     if ($value == '__custom__') {
         $value = isset($_REQUEST[$this->name . '_custom']) ? $_REQUEST[$this->name . '_custom'] : null;
     }
     if ($value) {
         parent::setValue($value);
     }
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:9,代码来源:MemberDatetimeOptionsetField.php

示例3: testReadonlyField

 public function testReadonlyField()
 {
     $sourceArray = array(0 => 'No', 1 => 'Yes');
     $field = new OptionsetField('FeelingOk', 'are you feeling ok?', $sourceArray, 1);
     $field->setEmptyString('(Select one)');
     $field->setValue(1);
     $readonlyField = $field->performReadonlyTransformation();
     preg_match('/Yes/', $field->Field(), $matches);
     $this->assertEquals($matches[0], 'Yes');
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:10,代码来源:OptionsetFieldTest.php

示例4: build

 /**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $options = array();
     foreach ($question->Values()->sort('Order') as $val) {
         $options[$val->ID] = empty($val->Label) ? $val->Value : $val->Label;
     }
     $field = new OptionsetField($question->name(), $question->label(), $options);
     $default_value = $question->getDefaultValue();
     if (!is_null($default_value) && $default_value->ID > 0) {
         $field->setValue($default_value->ID);
     }
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     $field->setTemplate('RSVPOptionSetField');
     return $this->buildDependantRules($rsvp, $question, $field);
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:29,代码来源:RSVPRadioButtonListQuestionTemplateUIBuilder.php

示例5: setValue

 public function setValue($value)
 {
     // Avoid setting blank as no
     if ($value === '' || $value === null) {
         return;
     }
     if ($value !== self::VALUE_YES && $value !== self::VALUE_NO) {
         if ((int) $value) {
             $value = self::VALUE_YES;
         } else {
             $value = self::VALUE_NO;
         }
     }
     parent::setValue($value);
 }
开发者ID:lekoala,项目名称:silverstripe-form-extras,代码行数:15,代码来源:YesNoOptionsetField.php

示例6: setValue

 /**
  * Load a value into this CheckboxSetField
  */
 public function setValue($value, $obj = null)
 {
     // If we're not passed a value directly, we can look for it in a relation method on the object passed as a
     // second arg
     if (!$value && $obj && $obj instanceof DataObject && $obj->hasMethod($this->name)) {
         $funcName = $this->name;
         $value = $obj->{$funcName}()->getIDList();
     }
     parent::setValue($value, $obj);
     return $this;
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:14,代码来源:CheckboxSetField.php

示例7: setValue

 public function setValue($value)
 {
     // Extract custom option from postback
     if (is_array($value)) {
         if (empty($value['Options'])) {
             $value = '';
         } elseif ($value['Options'] === self::CUSTOM_OPTION) {
             $value = $value['Custom'];
         } else {
             $value = $value['Options'];
         }
     }
     return parent::setValue($value);
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:14,代码来源:MemberDatetimeOptionsetField.php

示例8: setValue

 public function setValue($value, $obj = null)
 {
     if ($this->fieldType == 'CheckboxSetField') {
         CheckboxSetField::setValue($value, $obj);
     } else {
         parent::setValue($value);
     }
 }
开发者ID:betterbrief,项目名称:silverstripe-quickaddfield,代码行数:8,代码来源:QuickAddField.php

示例9: setValue

 /**
  * Load a value into this CheckboxSetField
  */
 function setValue($value, $obj = null)
 {
     // If we're not passed a value directly, we can look for it in a relation method on the object passed as a second arg
     if (!$value && $obj && $obj instanceof DataObject && $obj->hasMethod($this->name)) {
         $funcName = $this->name;
         $selected = $obj->{$funcName}();
         $value = $selected->toDropdownMap('ID', 'ID');
     }
     parent::setValue($value, $obj);
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:13,代码来源:CheckboxSetField.php


注:本文中的OptionsetField::setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。