src/Forms/FormField.php
public function setName(string $name)
    {
        $this->name = $name;
        while (preg_match('/^(.*)\[([^\]]*)\]$/', $name, $matches) === 1)
        {
            if (empty($matches[2]))
            {
                if ($this->name_depth > 1)
                    throw new \InvalidArgumentException("Invalid name: {$this->name}");
                $this->is_array = true;
            } 
            else
                array_unshift($this->name_parts, $matches[2]);

            $name = $matches[1];
            ++$this->name_depth;
        }
        array_unshift($this->name_parts, $name);

        return $this;
    }
public function setName(string $name)
    {
        $this->name = $name;
        while (preg_match('/^(.*)\[([^\]]*)\]$/', $name, $matches) === 1)
        {
            if (empty($matches[2]))
            {
                if ($this->name_depth > 1)
                    throw new \InvalidArgumentException("Invalid name: {$this->name}");
                $this->is_array = true;
            } 
            else
                array_unshift($this->name_parts, $matches[2]);

            $name = $matches[1];
            ++$this->name_depth;
        }
        array_unshift($this->name_parts, $name);

        return $this;
    }
public function setName ( string $ name ) { $ this -> name = $ name ; while ( preg_match ( '/^(.*)\[([^\]]*)\]$/' , $ name , $ matches ) === 1 ) { if ( empty ( $ matches [ 2 ] ) ) { if ( $ this -> name_depth > 1 ) throw new \ InvalidArgumentException ( "Invalid name: {$this->name}" ) ; $ this -> is_array = true ; } else array_unshift ( $ this -> name_parts , $ matches [ 2 ] ) ; $ name = $ matches [ 1 ] ; ++ $ this -> name_depth ; } array_unshift ( $ this -> name_parts , $ name ) ; return $ this ; }
Change the name of the field.
@param string $name The name to set. If the name contains [] pairs,
the field type will be set to array.
@return FormField Provides fluent interface
@throws InvalidArgumentException When an invalid names as used. An invalid name
is a name with more than one empty array pair,
like foo[][]
Change the name of the field .