本文整理汇总了PHP中Element::setRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setRequired方法的具体用法?PHP Element::setRequired怎么用?PHP Element::setRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::setRequired方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addElement
/**
* Add an element to the tray
*
* @param Element $formElement Element to add
* @param boolean $required true = entry required
*
* @return void
*/
public function addElement(Element $formElement, $required = false)
{
$this->elements[] = $formElement;
if ($required) {
$formElement->setRequired();
}
}
示例2: testIsRequired
/**
* @covers Xoops\Form\Element::isRequired
*/
public function testIsRequired()
{
$value = $this->object->isRequired();
$this->assertFalse($value);
$this->object->setRequired();
$value = $this->object->isRequired();
$this->assertTrue($value);
}
示例3: addElement
/**
* addElement - Add an element to the form
*
* @param Element $formElement Xoops\Form\Element to add
* @param boolean $required true if this is a required element
*
* @return void
*/
public function addElement(Element $formElement, $required = false)
{
/* @var Element $formElement */
$this->elements[] = $formElement;
if ($formElement instanceof ContainerInterface) {
/* @var $formElement ContainerInterface */
$required_elements = $formElement->getRequired();
$count = count($required_elements);
for ($i = 0; $i < $count; ++$i) {
$this->required[] = $required_elements[$i];
}
} else {
if ($required && !$formElement instanceof Raw) {
$formElement->setRequired();
$this->required[] = $formElement;
}
}
}
示例4: addElement
/**
* Adding new element
* @param Element $element
* @param bool $required
* @param bool $pre_fill
* @return Element
* @throws FormException
*/
public function addElement($element, $required = false, $pre_fill = true)
{
if ($element instanceof Element) {
$element->setRequired($required);
$element->setPreFill($pre_fill);
$this->elements[] = $element;
if ($element instanceof InputFile) {
$this->setEnctype('multipart/form-data');
}
return $element;
} else {
throw new FormException('element is not instance of class Element!');
}
}
示例5: setRequired
/**
* setRequired - mark an element as required entry
*
* @param Element $formElement Xoops\Form\Element to set as required entry
*
* @return void
*
* @deprecated set required attribute on element directly or when calling addElement
*/
public function setRequired(Element $formElement)
{
$formElement->setRequired();
}