/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/View/Form
NameSizeModeActions
ArrayContext.php108600644editdlrm
ContextFactory.php54160644editdlrm
ContextInterface.php41560644editdlrm
EntityContext.php230950644editdlrm
FormContext.php52280644editdlrm
NullContext.php27700644editdlrm
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/View/Form/FormContext.php (5228B)
null, ]; $this->_form = $context['entity']; } /** * Get the fields used in the context as a primary key. * * @return string[] * @deprecated 4.0.0 Renamed to {@link getPrimaryKey()}. */ public function primaryKey(): array { deprecationWarning('`FormContext::primaryKey()` is deprecated. Use `FormContext::getPrimaryKey()`.'); return []; } /** * @inheritDoc */ public function getPrimaryKey(): array { return []; } /** * @inheritDoc */ public function isPrimaryKey(string $field): bool { return false; } /** * @inheritDoc */ public function isCreate(): bool { return true; } /** * @inheritDoc */ public function val(string $field, array $options = []) { $options += [ 'default' => null, 'schemaDefault' => true, ]; $val = $this->_form->getData($field); if ($val !== null) { return $val; } if ($options['default'] !== null || !$options['schemaDefault']) { return $options['default']; } return $this->_schemaDefault($field); } /** * Get default value from form schema for given field. * * @param string $field Field name. * @return mixed */ protected function _schemaDefault(string $field) { $field = $this->_form->getSchema()->field($field); if ($field) { return $field['default']; } return null; } /** * @inheritDoc */ public function isRequired(string $field): ?bool { $validator = $this->_form->getValidator(); if (!$validator->hasField($field)) { return null; } if ($this->type($field) !== 'boolean') { return !$validator->isEmptyAllowed($field, $this->isCreate()); } return false; } /** * @inheritDoc */ public function getRequiredMessage(string $field): ?string { $parts = explode('.', $field); $validator = $this->_form->getValidator(); $fieldName = array_pop($parts); if (!$validator->hasField($fieldName)) { return null; } $ruleset = $validator->field($fieldName); if (!$ruleset->isEmptyAllowed()) { return $validator->getNotEmptyMessage($fieldName); } return null; } /** * @inheritDoc */ public function getMaxLength(string $field): ?int { $validator = $this->_form->getValidator(); if (!$validator->hasField($field)) { return null; } foreach ($validator->field($field)->rules() as $rule) { if ($rule->get('rule') === 'maxLength') { return $rule->get('pass')[0]; } } $attributes = $this->attributes($field); if (!empty($attributes['length'])) { return $attributes['length']; } return null; } /** * @inheritDoc */ public function fieldNames(): array { return $this->_form->getSchema()->fields(); } /** * @inheritDoc */ public function type(string $field): ?string { return $this->_form->getSchema()->fieldType($field); } /** * @inheritDoc */ public function attributes(string $field): array { $column = (array)$this->_form->getSchema()->field($field); $allowed = ['length' => null, 'precision' => null]; return array_intersect_key($column, $allowed); } /** * @inheritDoc */ public function hasError(string $field): bool { $errors = $this->error($field); return count($errors) > 0; } /** * @inheritDoc */ public function error(string $field): array { return (array)Hash::get($this->_form->getErrors(), $field, []); } }