本文整理汇总了PHP中Field::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Field::getName方法的具体用法?PHP Field::getName怎么用?PHP Field::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addField
/**
* @param Field $field
* @throws DuplicateFieldException
*/
public function addField(Field $field)
{
if (isset($this->fields[$field->getName()])) {
throw new DuplicateFieldException('Field `' . $field->getName() . '` already exists');
}
$this->fields[$field->getName()] = $field;
}
示例2: removeField
public function removeField(Field $field)
{
if (isset($this->fields[$field->getName()])) {
unset($this->fields[$field->getName()]);
}
return $this;
}
示例3: renderNonSelectField
/**
* Renders a non select field.
*
* @return string (X)HTML.
*/
protected function renderNonSelectField()
{
$o = '';
if (function_exists('advfrm_custom_field_default')) {
$val = advfrm_custom_field_default($this->form, $this->field->getName(), null, isset($_POST['advfrm']));
}
if (!isset($val)) {
$val = isset($_POST[$this->name]) ? stsl($_POST[$this->name]) : $this->field->getDefaultValue();
}
if ($this->field->getType() == 'textarea') {
$cols = $this->field->getColumnCount() ? $this->field->getColumnCount() : 40;
$rows = $this->field->getRowCount() ? $this->field->getRowCount() : 4;
$o .= '<textarea id="' . $this->id . '" name="' . $this->name . '" cols="' . $cols . '" rows="' . $rows . '">' . XH_hsc($val) . '</textarea>';
} elseif ($this->field->getType() == 'output') {
$o .= $val;
} else {
if ($this->field->getType() == 'date') {
$this->initDatePicker();
}
$size = $this->field->getType() == 'hidden' || $this->field->getSize() ? ' size="' . $this->field->getSize() . '"' : '';
$maxlen = in_array($this->field->getType(), array('hidden', 'file')) || !$this->field->getMaxLength() ? '' : ' maxlength="' . $this->field->getMaxLength() . '"';
if ($this->field->getType() == 'file' && $this->field->getMaxLength()) {
$o .= tag('input type="hidden" name="MAX_FILE_SIZE" value="' . $this->field->getMaxLength() . '"');
}
if ($this->field->getType() == 'file') {
$value = '';
$accept = ' accept="' . XH_hsc($this->prefixFileExtensionList($val)) . '"';
} else {
$value = ' value="' . XH_hsc($val) . '"';
$accept = '';
}
$o .= tag('input type="' . $this->getInputElementType() . '" id="' . $this->id . '" name="' . $this->name . '"' . $value . $accept . $size . $maxlen);
}
return $o;
}
示例4: addField
/**
* Add field
*
* @param Field $field
* @throws \LogicException
*/
public function addField(Field $field)
{
$name = $field->getName();
if (isset($this->fields[$name])) {
throw new \LogicException(sprintf('Field "%s" already exists', $name));
}
$this->fields[$name] = $field;
}
示例5: validateFilledInFieldCustom
/**
* Validates a filled in field wrt. custom constraints.
*
* @return string (X)HTML.
*/
protected function validateFilledInFieldCustom()
{
$o = '';
if (function_exists('advfrm_custom_valid_field')) {
$value = $this->field->getType() == 'file' ? $_FILES[$this->name] : stsl($_POST[$this->name]);
$valid = advfrm_custom_valid_field($this->formId, $this->field->getName(), $value);
if ($valid !== true) {
$o .= '<li>' . $valid . '</li>' . PHP_EOL;
Controller::focusField($this->formId, $this->name);
}
}
return $o;
}
示例6: renderField
/**
* Renders a field.
*
* @param Field $field A field.
*
* @return string
*/
protected function renderField(Field $field)
{
$name = 'advfrm-' . $field->getName();
$o = $field->getLabel() . PHP_EOL;
if (isset($_POST[$name])) {
if (is_array($_POST[$name])) {
foreach ($_POST[$name] as $val) {
$o .= ' ' . stsl($val) . PHP_EOL;
}
} else {
$o .= ' ' . $this->indent(stsl($_POST[$name])) . PHP_EOL;
}
} elseif (isset($_FILES[$name])) {
$o .= ' ' . stsl($_FILES[$name]['name']) . PHP_EOL;
}
return $o;
}
示例7: renderField
/**
* Renders a field.
*
* @param Field $field A field.
*
* @return string (X)HTML
*/
protected function renderField(Field $field)
{
$name = 'advfrm-' . $field->getName();
$o = '<tr><td class="label">' . XH_hsc($field->getLabel()) . '</td><td class="field">';
if (isset($_POST[$name])) {
if (is_array($_POST[$name])) {
foreach ($_POST[$name] as $val) {
$o .= '<div>' . XH_hsc(stsl($val)) . '</div>';
}
} else {
$o .= $this->nl2br(XH_hsc(stsl($_POST[$name])));
}
} elseif (isset($_FILES[$name])) {
$o .= stsl($_FILES[$name]['name']);
}
$o .= '</td></tr>' . PHP_EOL;
return $o;
}
示例8: testField
public function testField()
{
$f = new Field('test', 1);
$this->assertEquals('test', $f->getName());
$this->assertEquals(1, $f->getTable());
$f = new AllFields();
$this->assertEquals(0, $f->getTable());
$f = new AllFields(2);
$this->assertEquals(2, $f->getTable());
try {
$f = new Field(array('1'));
$this->fail('first parameter should be string (array is not allowed)');
} catch (InvalidArgumentException $e) {
}
try {
$f = new Field('foo', 'bar');
$this->fail('second parameter has to be numeric');
} catch (InvalidArgumentException $e) {
}
}
示例9: hasField
/**
* Returns TRUE whether the given field is contained in the fields collection
*
* @param Field $field
*
* @return boolean
*/
public function hasField(Field $field)
{
return array_key_exists($field->getName(), $this->fields);
}
示例10: add
public function add(Field $field)
{
$name = $field->getName();
$this->fields[$name] = $field;
}
示例11: removeField
/**
* Remove data field.
*
* @param Field $field Data field.
*/
public function removeField(Field $field)
{
if (isset($this->fields[$field->getName()])) {
unset($this->fields[$field->getName()]);
$this->length--;
}
}
示例12: addField
public function addField(Field $field)
{
$this->fields[$field->getName()] = $field;
return $this;
}
示例13: attachField
/**
* Adds field to model
* @param string $fieldName
* @param Field $field
*/
protected function attachField($field, $toBeginning = false)
{
if ($this->isFrozen()) {
throw new Exception("Unable to attach field '" . $field->getName() . "' to frozen model.");
}
if (key_exists($field->getName(), $this->fields)) {
throw new Exception("Field with name '" . $field->getName() . "' already exists in model '" . get_class($this) . "'");
}
if ($toBeginning) {
$this->fields = array($field->getName() => $field) + $this->fields;
} else {
$this->fields[$field->getName()] = $field;
}
//$this->fields[$field->getName()]->setModel($this);
return $this->fields[$field->getName()];
}
示例14: getAttributes
public function getAttributes(Field $field)
{
return $this->getConfigurationFor($field->getDocument())->findAttributes($field->getName());
}
示例15: addField
public function addField($name, $message = '')
{
$field = new Field($name, $message);
$this->fields[$field->getName()] = $field;
}