Pop\Form\Form::__construct PHP Method

__construct() public method

Instantiate the form object
public __construct ( string $action = null, string $method = 'post', array $fields = null, string $indent = null ) : Form
$action string
$method string
$fields array
$indent string
return Form
    public function __construct($action = null, $method = 'post', array $fields = null, $indent = null)
    {
        // Set the form's action and method.
        $this->action = null !== $action ? $action : $_SERVER['REQUEST_URI'];
        $this->method = $method;
        // Create the parent DOM element and the form child element.
        parent::__construct(null, 'utf-8', null, $indent);
        $this->form = new Child('form', null, null, false, $indent);
        $this->form->setAttributes(array('action' => $this->action, 'method' => $this->method));
        $this->addChild($this->form);
        if (null !== $fields) {
            $this->setFields($fields);
        }
    }

Usage Example

Example #1
0
 /**
  * Constructor
  *
  * Instantiate the form object
  *
  * @param  array  $fields
  * @param  string $action
  * @param  string $method
  * @return Role
  */
 public function __construct(array $fields = null, $action = null, $method = 'post')
 {
     parent::__construct($fields, $action, $method);
     $this->setAttribute('id', 'role-form');
     $this->setAttribute('class', 'data-form');
     $this->setIndent('    ');
 }
All Usage Examples Of Pop\Form\Form::__construct