本文整理汇总了PHP中Field::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Field::setValue方法的具体用法?PHP Field::setValue怎么用?PHP Field::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValue
function setValue($path)
{
if (!file_exists($this->imgDir . $path)) {
$path = $this->default;
}
parent::setValue($path);
}
示例2: add
public function add(Field $field)
{
$attr = $field->name();
$field->setValue($this->entity->{$attr}());
$this->fields[] = $field;
return $this;
}
示例3: add
/**
* Méthode permettant d'ajouter un champ à la liste
*
* @param \OCFram\Field $field
* @return \OCFram\Form
*/
public function add(Field $field)
{
$attr = $field->name();
// Récupérer le nom du champ
$field->setValue($this->entity->{$attr}());
// Assigner la valeur correspondante au champ
$this->fields[] = $field;
// Ajouter le champ passé en argument à la liste des champs
return $this;
}
示例4: testSettersAndGettersDoWhatTheyShould
public function testSettersAndGettersDoWhatTheyShould()
{
$field = new Field('type', 'element', 'label', 'description');
$field->setOptions(['options' => 'options']);
$field->setValidationRules('rules');
$field->setValue('foo');
$expectations = ['getOptions' => ['options' => 'options'], 'getValidationRules' => 'rules', 'getValue' => 'foo'];
foreach ($expectations as $method => $value) {
static::assertEquals($field->{$method}(), $value);
}
}
示例5: setValue
public function setValue($value)
{
if ($value === false) {
return parent::setValue('0');
} else {
if ($value === true) {
return parent::setValue('1');
} else {
return parent::setValue($value);
}
}
}
示例6: setValue
public function setValue($value)
{
parent::setValue($value);
if ($value == "") {
return;
}
$mainValue = $this->subModel->get(array("fields" => array($this->mainModel->getKeyField()), "conditions" => "{$this->subModel->getKeyField()}={$value}"), Model::MODE_ARRAY, false, false);
$this->mainSelectionList->setValue($mainValue[0][0]);
$subValues = $this->subModel->get(array("fields" => array($this->subModel->getKeyField(), $this->subModelPathInfo["field"]), "conditions" => "{$this->subModel->getKeyField()}={$value}"), Model::MODE_ARRAY, false, false);
foreach ($subValues as $subValue) {
$this->subSelectionList->addOption($subValue[1], $subValue[0]);
}
$this->subSelectionList->setValue($value);
}
示例7: setValue
public function setValue($value, $default = false)
{
if ($this->multiple) {
if (is_array($value)) {
foreach ($value as &$v) {
$v = (string) $v;
}
$this->value = $value;
} else {
$this->value = null;
}
} else {
parent::setValue($value, $default);
}
}
示例8: setWithDisplayValue
public function setWithDisplayValue($value)
{
$parts = explode("//", $value);
$mainId = $this->mainModel->getKeyField();
$mainField = Model::resolvePath($this->mainModelField);
$mainField = $mainField['field'];
$subField = Model::resolvePath($this->subModelField);
$subField = $subField['field'];
$possibleMainItem = reset($this->mainModel->getWithField2("trim({$mainField})", trim($parts[0])));
if ($possibleMainItem === false) {
parent::setValue(null);
return;
}
$possibleSubItem = reset($this->subModel->get(array('conditions' => "{$mainId} = {$possibleMainItem[$mainId]} and trim({$subField}) = '" . trim($this->mainModel->escape($parts[1])) . "'"), Model::MODE_ASSOC, false, false));
parent::setValue($possibleSubItem[$this->getName()]);
}
示例9: setValue
public function setValue($value, $default = false)
{
$set = false;
if (!is_string($value) && !is_float($value) && !is_int($value)) {
return;
}
foreach ($this->radios as $radio) {
if ($radio->getValue() == $value) {
$radio->setChecked(true);
$set = true;
} else {
$radio->setChecked(false);
}
}
parent::setValue($set ? $value : null);
}
示例10: parse
public static function parse($conf, $inputs)
{
$confPath = \Path::instance()->currentProject('etc.conf.@' . $conf . '.conf.xml');
if (!file_exists($confPath)) {
return false;
}
$dom = new \DOMDocument("1.0", "utf-8");
$dom->load($confPath);
$xpath = new \DOMXPath($dom);
$xpath->registerNamespace('bong', 'http://lab.zigmoyd.net/xmlns/bong');
$fieldNodes = $xpath->query("//bong:form/bong:field");
$form = new Form();
foreach ($fieldNodes as $fieldNode) {
$field = null;
$name = self::__attrValue($fieldNode, "name");
$default = self::__attrValue($fieldNode, "default");
if ($name) {
$field = new Field($name);
$required = self::__attrValue($fieldNode, "required", 'false');
if ($required == 'true') {
$field->setRequiredFlag(true);
}
if (isset($inputs[$name])) {
$field->setValue(strlen($inputs[$name]) > 0 ? $inputs[$name] : ($default ? $default : ''));
}
$ruleNodes = $xpath->query("bong:criteria", $fieldNode);
foreach ($ruleNodes as $ruleNode) {
$ruleName = self::__attrValue($ruleNode, 'name');
if ($ruleName) {
$arg = self::__attrValue($ruleNode, 'value');
$error = self::__attrValue($ruleNode, 'msg');
$rule = new RuleSet($ruleName, $error, $arg);
$field->addRuleSet($rule);
}
}
}
$form->addField($field);
}
return $form;
}
示例11: setupFields
/**
* This function gets the description of a table from the RDBMS and then constructs
* an array of Fields and returns them as required
*/
public function setupFields()
{
/*if(!$fields = Session::getRegistered($this->table_name.'_field_array'))
{*/
try {
$fields = FieldDefinitions::current()->definitionsForTable($this->table_name);
} catch (Exception $exc) {
if (!file_exists($this->fieldCachePath())) {
$query = SimpleQuery::create('describe ' . $this->table_name);
$fields = array();
while ($row = $query->next()) {
$type_array = preg_split('/\\(/', $row['Type']);
if ($row['Extra'] == 'auto_increment') {
$type = 'Field::T_AUTO';
} else {
if ($row['Key'] == 'PRI') {
$type = 'Field::T_PRIMARY_KEY_' . strtoupper($type_array[0]) . '';
} else {
$type = 'Field::T_' . strtoupper($type_array[0]) . '';
}
}
eval('$field_type = ' . $type . ';');
$field = new Field($this->table_name, $row['Field'], $field_type);
$fields[$row['Field']] = $field;
if ($row['Default'] || !$row['Default'] && is_numeric($row['Default'])) {
$field->setValue($row['Default']);
}
}
@unlink($this->fieldCachePath());
file_put_contents($this->fieldCachePath(), serialize($fields));
@chmod($this->fieldCachePath(), 0664);
} else {
if (file_exists($this->fieldCachePath())) {
$fields = unserialize(file_get_contents($this->fieldCachePath()));
}
}
//Session::register($this->table_name.'_field_array',$fields);
FieldDefinitions::current()->addDefinitionsForTable($this->table_name, $fields);
}
return $fields;
}
示例12: set
public function set($instance, Field $f, $value)
{
$f->setValue($instance, $value);
}
示例13: setValue
public function setValue($value)
{
if ($value == 't') {
$value = '1';
}
parent::setValue($value);
return $this;
}
示例14: setValue
/**
* Must be a ISO 8601 date string or a \DateTime object
* @param string|\DateTime $value
* @return $this
*/
public function setValue($value)
{
if ($value instanceof \DateTime) {
$value = $value->format('c');
}
return parent::setValue($value);
}
示例15: setValue
function setValue($v) {
parent::setValue((boolean)$v);
}