校验规则

@param  array  $attributes
@param  string $name
@param  array  $parameters

@return bool
188159
protected function validate(array $attributes, string $name, array $parameters): bool
    {
        if (isset($attributes[$name]) && ! empty($attributes[$name])) {
            return true;
        }

        $this->addError($name, $parameters, '%s 必须填写');

        return false;
    }
1072206
public function open(String $name = NULL, Array $_attributes = [])
    {
        $this->clearValidationSessions();

        $this->setFormName($name, $_attributes);

        $this->isEnctypeAttribute($_attributes);
       
        $this->isWhereAttribute($name);
        
        $this->isQueryAttribute();

        $this->isPreventAttribute();
        
        $this->setMethodType($_attributes);
        
        $this->createFormElementByAttributes($_attributes, $return);

        $this->isDatabaseProcessWithName($name, $return);

        $this->isCSRFAttribute($return);

        $this->_unsetopen();

        $this->outputElement .= $return;

        return $this;
    }
698993
public function define($name, $parameters = [], $parent = null, $children = [])
    {
        if (is_array($parent)) {
            $children = $parent;
            $parent = null;
        }
        if ($parent) {
            if (!array_has($this->items, $parent))
                throw new InvalidArgumentException("{$parent} does not exist");

            $name = "{$parent}.children.{$name}";

            if (empty($parameters['icon'])) $parameters['icon'] = 'fa-circle-o';
        } else {
            if (empty($parameters['icon'])) $parameters['icon'] = '';
        }
        if (empty($parameters['sort'])) $parameters['sort'] = 10;

        array_set($this->items, $name, $parameters);

        foreach ($children as $childName => $child) {
            $this->define($childName, $child, $name);
        }
    }
377774
final public function tag(string $name, array $attributes = [])
    {
        if ('' === $name) {
            throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.');
        }

        foreach ($attributes as $attribute => $value) {
            if (null !== $value && !is_scalar($value)) {
                throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute));
            }
        }

        $this->definition->addTag($name, $attributes);

        return $this;
    }
128062
public function addOption($name, array $attributes)
    {
        /**
         * @var Route $route
         */
        foreach ($this->routes as $route) {
            $route->addOption($name, $attributes);
        }
    }
1173471
protected function validate(array $attributes, string $name, array $parameters = []): bool
    {
        $callback = $this->callback;

        if (($result = $callback($attributes, $name, $parameters)) === false) {
            $this->addError($name, $parameters, 'verification failed');
        }

        unset($callback);

        return $result;
    }
856955
public static function link($name, $url, array $attributes = [])
    {
        return static::openTag('link', array_merge($attributes, ['href' => $url])).
            $name.
            static::closeTag('link');
    }
1037573
private static function checkDataAttribute(array &$attributes, $name, array $supported, $default)
    {
        $attribute = $attributes[$name] ?? null;

        if ( ! is_null($attribute)) {
            $attribute = (is_string($attribute) && in_array($attribute, $supported))
                ? strtolower(trim($attribute))
                : $default;

            $attributes[$name] = $attribute;
        }
    }
542139
public function getFilterByName($name, $attributes = [])
    {
        $filter = null;
        $name = str_replace('\\', DS, ucfirst($name)) . 'Filter.php';
        $file = $this->loader->findFirst($this->application->config('directory.filter') . DS . $name);
        if ($file) {
            $class = $file->getClassName();
            $filter = new $class();
        }

        // not found.
        if (! $filter) {
            throw new Exception\NotFoundException('No such filter. -> ' . $name);
        }
        
        $filter->setAttributes($attributes);
        $filter->setContainer($this->container);
        $this->container->injectDependency($filter);
        return $filter;
    }
936515
protected function addMethod($name, $parameters)
    {
        $methods = $this->methods();

        $parameters = is_array($parameters) ? $parameters : [$parameters];

        $methods[] = compact('name', 'parameters');

        $this->methods($methods);
    }
222911
private static function validateAttributes($model, $name, &$attributes)
    {
        // Should be an array.
        if (!is_array($attributes)) {
            $attributes = [$attributes];
        }

        // Is empty, use the name of the table + name.
        if (empty($attributes)) {
            $attributes = [sprintf('%s.%s', $model->getTable(), $name)];
        }

        // Check each of the attribute values.
        // Convert any prepended with a curly to an expression.
        foreach ($attributes as &$value) {
            if (substr($value, 0, 1) === '#' || substr($value, 0, 1) === '{') {
                $value = new Expression(substr($value, 1));
            }
        }
    }
1086442
public function save($name, $attributes = [])
    {
        if (auth()->guest()) {
            return;
        }
        $params          = [
            'uid'      => auth()->user()->id,
            'brand_id' => brand_id(),
            'resource' => uri(),
            'name'     => snake_case($name),
            'data'     => $attributes,
        ];
        $this->cache->forget($this->cacheKey($params));
        $wid             = $this->getComponentId($name);
        $params['wid']   = $wid;
        $componentParams = ComponentParams::firstOrNew($params);
        $componentParams->save();
        return $componentParams;
    }
1012931
public static function attributes( $attributes, $name = null, $type = null, $options = null ) {

		$attributes = (array) apply_filters( "pods_form_ui_field_{$type}_attributes", $attributes, $name, $options );

		foreach ( $attributes as $attribute => $value ) {
			if ( null === $value ) {
				continue;
			}

			echo ' ' . esc_attr( (string) $attribute ) . '="' . esc_attr( (string) $value ) . '"';
		}
	}
615008
public function getAttributes($name, $options = null)
    {
        $attributes = '';

        if (!is_array($options[$name])) {
            return $attributes;
        }

        foreach ($options[$name] as $key => $value) {
            if ($key !== 'tag' && $key !== 'value') {
                $value = is_callable($value) ? $value($options[$name], $options) : $value;
                $attributes .= !empty($value) ? ' ' . $key . '="' . $value . '"' : '';
            }
        }

        return $attributes;
    }
1180452
protected function validate(array $attributes, string $name, array $parameters): bool
    {
        if (isset($parameters['domain']) && ! Assert::email($attributes[$name], $parameters['domain'])) {
            $this->addError($name, $parameters, '%s 超出允许邮箱范围');

            return false;
        }

        if (! Assert::email($attributes[$name])) {
            $this->addError($name, $parameters, '%s 必须为 Email');

            return false;
        }

        return true;
    }
244151
public static function selectField( $name, $options, $attributes, $value = null, $fieldProperties = null, $ID = null )
    {
        if( empty( $name ) ) {
            return false;
        }

        if( empty( $options ) ) {
            trigger_error("Object <strong>{$name}</strong> has no valid options!", E_USER_WARNING);
            return false;
        }

        $fieldProperties   = empty( $fieldProperties ) ? array() : ( is_array($fieldProperties) ? $fieldProperties : array( $fieldProperties ) );
        $baseAttributes    = array( 'ID' => $name, 'name' => $name );
        $source            = '';
        $hasSelectedOption = false;

        foreach( $options as $item ) {
            $option         = '';
            $selectedOption = '';

            if( !$hasSelectedOption && ( isset( $item['selected'] ) || ( $item == $value ) || ( isset( $item['value'] ) && $value == $item['value'] ) ) ) {
                $selectedOption    = 'selected="selected"';
                $hasSelectedOption = true;
            }

            if( !is_array($item) ) {
                $option .= "<option {$selectedOption} value=\"{$item}\">{$item}</option>";
            } else {
                $option = "<option ";
                if( isset( $item['value'] ) ) {
                    $option .= " value=\"{$item['value']}\" {$selectedOption}";
                } else {
                    $option .= " value=\"{$item['text']}\" {$selectedOption}";
                }

                $option = trim($option) . ">{$item['text']}</option>";
            }
            $source .= $option;
        }

        $attsString = self::arrayToHTMLAttributes(array_merge($baseAttributes, $attributes));
        $output     = "<select {$attsString}>{$source}</select>";

        $field             = new \stdClass();
        $field->html       = $output;
        $field->properties = array_merge($baseAttributes, $attributes, array( 'options' => $options ), $fieldProperties);

        return $field;
    }
534076
public function issetAttribute($name)
    {
        try {
            if (parent::__get($name) !== null) {
                return true;
            }
        } catch (Exception $ignore) {
        }

        $path = explode('.', $name);
        $ref = &$this->_dynamicAttributes;

        foreach ($path as $key) {
            if (!isset($ref[$key])) {
                return false;
            }
            $ref = &$ref[$key];
        }

        return true;
    }