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


PHP CheckboxField::performReadonlyTransformation方法代码示例

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


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

示例1: performReadonlyTransformation

 /**
  * Return a readonly version of this field. Keeps the composition but returns readonly
  * versions of all the child {@link FormField} objects.
  *
  * @return CompositeField
  */
 public function performReadonlyTransformation()
 {
     parent::performReadonlyTransformation();
     $newChildren = new FieldList();
     $clone = clone $this;
     if ($clone->getChildren()) {
         foreach ($clone->getChildren() as $idx => $child) {
             if (is_object($child)) {
                 $child = $child->transform(new ReadonlyTransformation());
             }
             $newChildren->push($child, $idx);
         }
     }
     $clone->children = $newChildren;
     $clone->readonly = true;
     $clone->addExtraClass($this->extraClass());
     $clone->setDescription($this->getDescription());
     return $clone;
 }
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:25,代码来源:BootstrapToggleField.php

示例2: testReadonlyCheckboxField

 public function testReadonlyCheckboxField()
 {
     // Test 1: a checked checkbox goes to "Yes"
     $field1 = new CheckboxField('IsChecked', 'Checked');
     $field1->setValue('on');
     $copy = $field1->performReadonlyTransformation();
     $this->assertEquals(_t('CheckboxField.YESANSWER', 'Yes'), trim(strip_tags($field1->performReadonlyTransformation()->Field())));
     // Test 2: an checkbox with the value set to false to "No"
     $field2 = new CheckboxField('IsChecked', 'Checked');
     $field2->setValue(false);
     $this->assertEquals(_t('CheckboxField.NOANSWER', 'No'), trim(strip_tags($field2->performReadonlyTransformation()->Field())));
     // Test 3: an checkbox with no value ever set goes to "No"
     $field3 = new CheckboxField('IsChecked', 'Checked');
     $this->assertEquals(_t('CheckboxField.NOANSWER', 'No'), trim(strip_tags($field3->performReadonlyTransformation()->Field())));
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:15,代码来源:CheckboxFieldTest.php


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