Set "Object already exists" error
@param string $field
@param string $label
@return array
501162
protected function setErrorExists($field, $label)
    {
        $error = $this->translation->text('@name already exists', array('@name' => $label));
        return $this->setError($field, $error);
    }
1362144
public function valueExists($field, $value = null)
    {
        $record = new static($this->table, $this->keys, $this->mapper);

        if ($value === null) {
            $value = $this->$field;
        }

        try {
            $record->load([$field => $value]);
        } catch (NoResultException $e) {
            return false;
        }

        if ($record->$field != $value) {
            return false;
        }

        // check record keys same as self
        $same = [];

        foreach ($this->keys as $key) {
            $same[] = ($record->$key == $this->$key);
        }

        // Key not same, means same value exists in other record.
        if (in_array(false, $same, true)) {
            return true;
        }

        return false;
    }
728136
public function file($field, $label) {
        $file = new File($this->_entity, $field, $label);
        array_push($this->_elements, $file);

        return $file;
    }
1345333
function field($label, $fieldname, $fieldtype) {
		// field type loaders
		$fieldtypes = $this->confs->read('ran/htmlform')['fieldtypes'];

		if (isset($fieldtypes[$fieldtype])) {
			$instance = $fieldtypes[$fieldtype]($this, $this->confs);
		}
		else { # assume specialized class definition with no fieldtype loader
			$class = \hlin\PHP::pnn('ran.'.ucfirst($fieldtype).'Field');
			$instance = $class::instance($this->confs);
		}

		// configure and return
		return $instance
			->set('id', $this->signature($this->fieldcounter++))
			->set('name', $fieldname)
			->form_is($this)
			->fieldlabel_is($label)
			->fieldtemplate_is($this->fieldtemplate($fieldtype))
			->fieldconfigurer_is($this->fieldconfigurer($fieldtype))
			->hintrenderer_is($this->hintrenderer($fieldtype))
			->errorrenderer_is($this->errorrenderer($fieldtype))
			->adderrors($this->errors($fieldname));
	}
609152
private function _setLabel($label) {
		if ($label && is_array($label)) {
			$this->label = $label;
			return true;
		}

		$singular = $this->singular;
		$plural = $this->plural ?: $singular . $this->plural_end;

		$this->label = array(
			'name' => ucfirst($plural),
			'singular' => ucfirst($singular),
			'menu_name' => ucfirst($singular),
			'all_items' => __('All', 'wba_taxonomy') . ' ' . $plural,
			'parent_item' => __('Parent', 'wba_taxonomy') . ' ' . $singular,
			'parent_item_colon' => __('Parent', 'wba_taxonomy') . ' ' . $singular,
			'new_item_name' => __('New', 'wba_taxonomy') . ' ' . $singular,
			'add_new_item' => __('Add New', 'wba_taxonomy') . ' ' . $singular,
			'edit_item' => __('Edit', 'wba_taxonomy') . ' ' . $singular,
			'update_item' => __('Update', 'wba_taxonomy') . ' ' . $singular,
			'view_item' => __('View', 'wba_taxonomy') . ' ' . $singular,
			'separate_items_with_commas' => __('Separate', 'wba_taxonomy') . strtolower($singular) . ' ' . __('with commas', 'wba_taxonomy'),
			'add_or_remove_items' => __('Add or remove', 'wba_taxonomy') . strtolower($singular),
			'choose_from_most_used' => __('Choose from the most used', 'wba_taxonomy'),
			'popular_items' => ucfirst($plural),
			'search_items' => __('Search', 'wba_taxonomy') . ' ' . $singular,
			'not_found' => __('Not Found', 'wba_taxonomy'),
			'no_terms' => __('No', 'wba_taxonomy') . ' ' . $singular,
			'items_list' => ucfirst($singular) . ' ' . __('list', 'wba_taxonomy'),
			'items_list_navigation' => ucfirst($singular) . ' ' . __('list navigation', 'wba_taxonomy'),
		);

		return true;
	}
379266
private function value($value, string $label = ''): void
    {
        if (is_scalar($value)) {
            $this->scalar($value, $label);
        } elseif (is_array($value)) {
            $this->iterable($value, $label);
        } elseif (is_object($value)) {
            $this->object($value, $label);
        }
    }
487625
public function updateField($field)
    {
        if (!$field instanceof ObjectField)
        {
            throw new FieldEditorException(print_r($field, true) . " is not of type ObjectField");
        }
        foreach ($this->_fields as $column => $fields)
        {
            foreach ($fields as $index => $f)
            {
                $existing_field = $f->getField();
                if ($existing_field !== null && $field->getField() === $existing_field)
                {
                    // If the field name (f1234) exists merge replace on that.
                    $this->_fields[$column][$index] = $field;
                    return;
                }
            }
        }
        throw new FieldEditorException("Could not find an existing field: {$field->getField()} in this Section");
    }
1209880
public function validateName($label)
    {
        if (empty($label)) {
            $this->addError('name', 'Name cannot be empty');
            return false;
        }

        if (!is_string($label)) {
            $this->addError('name', 'Name must be a string');
            return false;
        }

        if (mb_strlen($label, 'UTF-8') > 255) {
            $this->addError('name', 'Name length has to be less or equal to 255');
            return false;
        }

        return true;
    }
569617
public function setLabel(Label $label)
    {
        $label->checkId();
        $label->setScriptEvents(true);
        $this->label = $label;
        return $this;
    }
1360854
protected function setErrorRequired($field, $label)
    {
        $error = $this->translation->text('@field is required', array('@field' => $label));
        return $this->setError($field, $error);
    }
613350
public function setLabel($label) : self
    {
        if (!$label instanceof Label && !$label instanceof HtmlElement) {
            $label = new Label($label);
        }

        $this->label = $label;

        if (!$this->field->getId() && $this->label instanceof Label) {
            $this->label->setFor($this->field->generateId()->getId());
        }

        if (!$this->getPlaceholder() && $this->label->getContent()) {
            $this->setPlaceholder($this->label->getContent());
        }

        return $this;
    }
894261
protected function filterCompare($field, $details, $label, $message) {
        if (isset($details['value'])) {
            $value = $details['value'];
            $secondLabel = '';
        } else {
            $value = $this->getValue($details['column']);
            $secondLabel = isset($this->labels[$details['column']]) ? $this->labels[$details['column']] : ucwords(str_replace('_', ' ', $details['column']));
        }

        if (!isset($details['sign']) || '==' == $details['sign']) {
            if ($this->getValue($field) == $value) {
                return true;
            }
            throw new \Exception($message ? $message : $this->translate(isset($details['value']) ? "Invalid value!" : "$label can't be different than $secondLabel!"));
        } else {
            $result = eval("return \$this->getValue(\$field) $details[sign] \$value");
            if ($result) {
                return true;
            }
            throw new \Exception($message ? $message : $this->translate("Invalid value!"));
        }
    }
845126
public static function getInstance($label = 'default')
    {
      $instance = null;

      if(!isset(self::$instances[$label]))
      {
          // Create new Client
          $client = new Client();

          // Save the instance
          self::$instances[$label] = $client;
      }

      $instance = self::$instances[$label];

      return $instance;
    }
31846
protected function setErrorInteger($field, $label)
    {
        $error = $this->translation->text('@field must be integer', array('@field' => $label));
        return $this->setError($field, $error);
    }
59019
protected function _findObject($label)
    {
        $result    = false;
        $signature = null;

        $method = sprintf('_get%sSignature', ucfirst($label));

        if (method_exists($this, $method)) {
            $signature = $this->$method();
        }

        if (is_null($signature) || !isset(self::$_find_results[$signature]))
        {
            $method = '_findActivity' . ucfirst($label);

            if (method_exists($this, $method)) {
                $result = (bool) $this->$method();
            }

            if ($signature) {
                self::$_find_results[$signature] = $result;
            }
        }
        else $result = self::$_find_results[$signature];

        return $result;
    }
512597
public function error($field)
    {
        $parts = explode('.', $field);
        $entity = $this->entity($parts);

        if ($entity instanceof EntityInterface) {
            return $entity->getError(array_pop($parts));
        }

        return [];
    }
1354386
protected function addAddress($address, $label, $field)
    {
        $label = is_string($label) ? trim($label) : $label;
        $address = is_string($address) ? trim($address) : $label;

        $label = $label ?: $address;

        if (!empty($address)) {
            $this->{$field}[$address] = $label;
        }
    }