本文整理匯總了PHP中Nette\Forms\Controls\BaseControl::getValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseControl::getValue方法的具體用法?PHP BaseControl::getValue怎麽用?PHP BaseControl::getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Forms\Controls\BaseControl
的用法示例。
在下文中一共展示了BaseControl::getValue方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save
/**
* @param object $object
* @param string $fieldName
* @param BaseControl $control
* @param IClassMetadata $classMetadata
* @throws \NForms\Exceptions\UnexpectedTypeException
* @return bool
*/
public function save($object, $fieldName, BaseControl $control, IClassMetadata $classMetadata)
{
if ($control->isOmitted() || $control->isDisabled()) {
return TRUE;
}
$value = $control->getValue();
if ($classMetadata->hasAssociation($fieldName) && $value !== NULL) {
if ($classMetadata->isSingleValuedAssociation($fieldName)) {
$value = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $value);
} else {
if (!is_array($value) && (!$value instanceof \ArrayAccess || !$value instanceof \Iterator)) {
throw new UnexpectedTypeException("In mapping association {$classMetadata->getClass()}::\${$fieldName} - expected array or ArrayAccess and Iterator instance, given " . get_class($value) . ".");
}
$collection = array();
foreach ($value as $id) {
$collection[] = $this->objectManager->find($classMetadata->getAssociationTargetClass($fieldName), $id);
}
$value = $collection;
}
}
if ($classMetadata->hasAssociation($fieldName)) {
$classMetadata->setAssociationValue($object, $fieldName, $value);
} else {
if ($control instanceof Nette\Forms\Controls\TextBase && $value === '') {
$value = NULL;
}
$classMetadata->setFieldValue($object, $fieldName, $value);
}
return TRUE;
}
示例2: toPropertyValue
public function toPropertyValue(\Nette\Forms\Controls\BaseControl $control, Builder\Metadata $metadata)
{
$value = $control->getValue();
if ($value !== null) {
$value = $metadata->type === 'float' ? (double) $value : (int) $value;
}
return $value;
}
示例3: getValue
/**
* Returns control's value.
*
* @return int|\DateTime
*/
public function getValue()
{
if ($this->type === self::DATETIME) {
return parent::getValue();
} else {
return parent::getValue()->getTimestamp();
}
}
示例4: addNominalDiscountControl
private function addNominalDiscountControl(BaseControl $priceControl)
{
$errorMessage = 'Nominal discount must be between 0 and original price.';
$control = $this->addText('nominalDiscount', 'Nominal discount');
$control->setType('number')->setAttribute('step', 'any')->setDefaultValue(0)->addRule(self::FLOAT, $errorMessage)->addRule(function (TextInput $input) use($priceControl) {
return $input->getValue() >= 0 && $input->getValue() < $priceControl->getValue();
}, $errorMessage);
if ($this->editedProduct !== null) {
$control->setDefaultValue($this->editedProduct->getNominalDiscount());
}
}
示例5: getRawValue
/**
* @return mixed
*/
public function getRawValue()
{
return parent::getValue();
}
示例6: toPropertyValue
public function toPropertyValue(\Nette\Forms\Controls\BaseControl $control, Builder\Metadata $metadata)
{
return $control->getValue();
}