本文整理汇总了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;
}
示例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())));
}