Adds a new custom element.

@param string $name
@param array $attributes
@return Custom
975241
public function custom(string $name, array $attributes): Custom
    {
        /** @var ContainerElement $this */
        return $this->addElement(Custom::factory($name, $attributes));
    }
1176568
public function addHidden($name, $attr = [])
    {
        $e = new \FrenchFrogs\Form\Element\Hidden($name, $attr);
        $this->addElement($e);
        return $e;
    }
1189652
public function addConstraint($name, array $attributes = [])
    {
        if ($this->scope == 'alter') {
            $command = 'ADD CONSTRAINT';
        } else {
            $command = 'CONSTRAINT';
        }

        $sql = sprintf(
            '%s (%s) FOREIGN KEY (`%s`) REFERENCES %s(%s) ON %s',
            $command,
            $name,
            $attributes['target'],
            $attributes['table'],
            $attributes['references'],
            strtoupper($attributes['on'])
        );

        $this->sqls[] = $sql;

        return $this;
    }
241942
public function select($name, $options = null, $attributes = array())
    {
        $attributes['name'] = $name;

        if (!isset($attributes['id'])) {
            $attributes['id'] = str_replace(array('[', ']'), array('_', ''), $name);
        }

        if (is_array($options)) {
            $options = array_merge(array('options' => array(), 'selected' => null), $options);
            $options = $this->options($options['options'], @$options['selected']);
        }

        return $this->tag('select', (string) $options, $attributes);
    }
886770
protected function persist($name, array $attributes = [])
    {
        $entity = $this->build($name, $attributes);

        $this->assignRelationships($entity, $attributes);
        $this->model->save($entity);

        return $entity;
    }
1152252
public function addAttributes(array $attributes)
	{
		foreach($attributes as $attrName => $attrValue) {
			$this->addAttribute($attrName, $attrValue);
		}
	}
2925
public function addElement($tag, array $attributes = [])
    {
        if ($tag instanceof self) {
            $htmlTag      = $tag;
            $htmlTag->top = $this->top;
            $htmlTag->attrs($attributes);
            $this->elements->add($htmlTag);

            return $htmlTag;
        }

        return self::make(
            $tag,
            $attributes,
            $this->hasParent() ? $this->parent : $this
        );
    }
1222780
public function define($name, $shortName = '', $attributes = [])
    {
        // The short name is optional. We'll do a quick check
        // to keep the API as simple as possible to use.

        if (is_array($shortName) || $shortName instanceof Closure) {
            $attributes = $shortName;
            $shortName = '';
        }

        $this->definitions[] = new Definition($name, $shortName, $attributes);

        return $this;
    }
1121841
protected function createMenuItem($name, $attributes)
    {
        $icon = array_get($attributes, 'attributes.data-icon', '');
        return new Fluent([
            "icon"   => starts_with($icon, 'zmdi') ? $icon : 'zmdi-' . $icon,
            "link"   => array_get($attributes, 'url'),
            "title"  => array_get($attributes, 'title'),
            "id"     => $name,
            "childs" => []
        ]);
    }
913620
public static function create(array $attributes = [])
    {
        return tap(self::make(call_user_func_array([static::$client, 'create'], func_get_args())), function ($model) {
            $model->exists = true;
        });
    }
251311
public function addFilter($name, $attributes = array())
    {
        // name is "filtername:method:alias".
        $names = explode(':', $name);
        $filter = array_shift($names);
        $method = array_shift($names);
        $alias = array_shift($names);
        if (! $alias) $alias = $filter;
        if (! is_array($attributes)) $attributes = [];

        // method miss match, when return.
        if ($method && strtoupper($method) !== $this->Request->getMethod()) return;

        // register.
        if (isset($this->filters[$alias])) {
            $this->filters[$alias]['attributes'] = $this->arrayUtil->merge($this->filters[$alias]['attributes'], $attributes);
        } else {
            $this->filter_names[] = $alias;
            $this->filters[$alias] = array('name' => $filter, 'attributes' => (array)$attributes);
        }

        // if action filter.
        if (strtolower($filter) === 'action') {
            $this->has_action_filter = true;
        }
    }
1151458
public static function tag($name, $content = NULL, Array $attributes = NULL) {
    $tag = new HTMLTag($name, $content, $attributes);
    return $tag;
  }
579455
public function create($name, $attrs = NULL)
	{
		$this->insert(NULL, $child = static::el($name, $attrs));

		return $child;
	}
182554
public function addField(array $attributes)
    {
        $field = $this->fields()->create($attributes);

        $this->save();

        return $field;
    }
611821
public function add(array $attributes)
    {
        foreach ($attributes as $key => $values) {
            $this->set($key, $values);
        }

        return $this;
    }
919603
public function addForeign($name, array $attributes = [])
    {
        if ($this->scope == 'alter') {
            $command = 'ADD ';
        } else {
            $command = '';
        }

        $on = '';
        $references = '';

        if (isset($attributes['on'])) {
            $on = strtoupper(' ON ' .$attributes['on']);
        }

        if (isset($attributes['references'])) {
            $references = sprintf(
                ' REFERENCES %s(%s)',
                $attributes['table'],
                $attributes['references']
            );
        }

        $sql = sprintf(
            '%sFOREIGN KEY (`%s`)%s%s',
            $command,
            $name,
            $references,
            $on
        );

        $this->sqls[] = $sql;

        return $this;
    }
470318
public function addMany(array $attributes)
    {
        if (count($attributes) > 0) {
            foreach($attributes as $name => $value) {
                $this->add($name, $value);
            }
        }

        return $this;
    }