public function create($mixed = null, $options = array())
    {
        $this->request = Strata::router()->getCurrentController()->request;

        if (!is_null($mixed) && !in_array('Strata\\Model\\CustomPostType\\ModelEntity', class_parents($mixed))) {
            throw new Exception("A form can only be linked to either an object inheriting ModelEntity or nothing at all.");
        }

        if (is_object($mixed)) {
            $this->associatedEntity = $mixed;
        }

        $this->configuration = $this->parseFormConfiguration($options);

        $formAttributes = $this->configuration;
        unset($formAttributes['hasSteps']);
        unset($formAttributes['type']);
        unset($formAttributes['nonce']);

        if (!is_null($this->associatedEntity) && $this->associatedEntity->hasValidationErrors()) {
            if (array_key_exists('class', $formAttributes)) {
                $formAttributes['class'] .= " has-errors ";
            } else {
                $formAttributes['class'] = "has-errors";
            }
        }

        $htmlAttributes = $this->arrayToHtmlAttributes($formAttributes);

        $salt = $this->getNonceSalt();
        $nonceTag = $this->generateNonceTag($salt);
        $nonceHidden = $this->generateHidden(array("name" => "auth_id"), wp_create_nonce($salt));

        return sprintf("<form %s>\n%s\n%s\n", $htmlAttributes, $nonceHidden, $nonceTag);
    }
public function create($mixed = null, $options = array())
    {
        $this->request = Strata::router()->getCurrentController()->request;

        if (!is_null($mixed) && !in_array('Strata\\Model\\CustomPostType\\ModelEntity', class_parents($mixed))) {
            throw new Exception("A form can only be linked to either an object inheriting ModelEntity or nothing at all.");
        }

        if (is_object($mixed)) {
            $this->associatedEntity = $mixed;
        }

        $this->configuration = $this->parseFormConfiguration($options);

        $formAttributes = $this->configuration;
        unset($formAttributes['hasSteps']);
        unset($formAttributes['type']);
        unset($formAttributes['nonce']);

        if (!is_null($this->associatedEntity) && $this->associatedEntity->hasValidationErrors()) {
            if (array_key_exists('class', $formAttributes)) {
                $formAttributes['class'] .= " has-errors ";
            } else {
                $formAttributes['class'] = "has-errors";
            }
        }

        $htmlAttributes = $this->arrayToHtmlAttributes($formAttributes);

        $salt = $this->getNonceSalt();
        $nonceTag = $this->generateNonceTag($salt);
        $nonceHidden = $this->generateHidden(array("name" => "auth_id"), wp_create_nonce($salt));

        return sprintf("<form %s>\n%s\n%s\n", $htmlAttributes, $nonceHidden, $nonceTag);
    }
public function create ( $ mixed = null , $ options = array ( ) ) { $ this -> request = Strata :: router ( ) -> getCurrentController ( ) -> request ; if ( ! is_null ( $ mixed ) && ! in_array ( 'Strata\\Model\\CustomPostType\\ModelEntity' , class_parents ( $ mixed ) ) ) { throw new Exception ( "A form can only be linked to either an object inheriting ModelEntity or nothing at all." ) ; } if ( is_object ( $ mixed ) ) { $ this -> associatedEntity = $ mixed ; } $ this -> configuration = $ this -> parseFormConfiguration ( $ options ) ; $ formAttributes = $ this -> configuration ; unset ( $ formAttributes [ 'hasSteps' ] ) ; unset ( $ formAttributes [ 'type' ] ) ; unset ( $ formAttributes [ 'nonce' ] ) ; if ( ! is_null ( $ this -> associatedEntity ) && $ this -> associatedEntity -> hasValidationErrors ( ) ) { if ( array_key_exists ( 'class' , $ formAttributes ) ) { $ formAttributes [ 'class' ] .= " has-errors " ; } else { $ formAttributes [ 'class' ] = "has-errors" ; } } $ htmlAttributes = $ this -> arrayToHtmlAttributes ( $ formAttributes ) ; $ salt = $ this -> getNonceSalt ( ) ; $ nonceTag = $ this -> generateNonceTag ( $ salt ) ; $ nonceHidden = $ this -> generateHidden ( array ( "name" => "auth_id" ) , wp_create_nonce ( $ salt ) ) ; return sprintf ( "<form %s>\n%s\n%s\n" , $ htmlAttributes , $ nonceHidden , $ nonceTag ) ; }
Opens up a form tag
@param  mixed   ModelEntity or null
@param  array  $options
@return string
Opens up a form tag