src/PeekAndPoke/Component/Formal/Form.php
public function submit($data)
    {
        if ($this->submitted) {
            throw new \LogicException('The form is already submitted. Cannot do this twice!');
        }

        if (! $this->finalized) {
            $this->finalize();
        }

        // are we on the top level
        if ($this->getParent() === null) {
            // has this form been submitted?
            if (! isset($data[$this->getId()])) {
                return $this;
            }
            // we have to grab our data first
            $data = $data[$this->getId()];
        }

        // really submit
        parent::submit($data);

        // iterate our field and individually submit the values we received
        foreach ($this->children as $child) {
            // only submit fields that are not read-only
            if ($child->isReadOnly() === false) {
                $id = $child->getId();
                $child->submit($data[$id] ?? null);
            }
        }

        return $this;
    }
public function submit($data)
    {
        if ($this->submitted) {
            throw new \LogicException('The form is already submitted. Cannot do this twice!');
        }

        if (! $this->finalized) {
            $this->finalize();
        }

        // are we on the top level
        if ($this->getParent() === null) {
            // has this form been submitted?
            if (! isset($data[$this->getId()])) {
                return $this;
            }
            // we have to grab our data first
            $data = $data[$this->getId()];
        }

        // really submit
        parent::submit($data);

        // iterate our field and individually submit the values we received
        foreach ($this->children as $child) {
            // only submit fields that are not read-only
            if ($child->isReadOnly() === false) {
                $id = $child->getId();
                $child->submit($data[$id] ?? null);
            }
        }

        return $this;
    }
public function submit ( $ data ) { if ( $ this -> submitted ) { throw new \ LogicException ( 'The form is already submitted. Cannot do this twice!' ) ; } if ( ! $ this -> finalized ) { $ this -> finalize ( ) ; } // are we on the top level if ( $ this -> getParent ( ) === null ) { // has this form been submitted? if ( ! isset ( $ data [ $ this -> getId ( ) ] ) ) { return $ this ; } // we have to grab our data first $ data = $ data [ $ this -> getId ( ) ] ; } // really submit parent :: submit ( $ data ) ; // iterate our field and individually submit the values we received foreach ( $ this -> children as $ child ) { // only submit fields that are not read-only if ( $ child -> isReadOnly ( ) === false ) { $ id = $ child -> getId ( ) ; $ child -> submit ( $ data [ $ id ] ?? null ) ; } } return $ this ; }
@param $data

@return $this
@param $data