Skip to content
Snippets Groups Projects
Select Git revision
  • d6c43c7620e631cedad0d608e92d9766809481e6
  • master default protected
  • devel
  • feature/add-escaping-to-templates
  • feature/add-priority-sorting
  • 3.3.0
  • 3.2.1
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 2.4.12
  • 2.4.11
  • 2.4.10
  • 2.4.9
  • 2.4.8
  • 2.4.7
  • 2.4.6
  • 2.4.5
  • 2.4.4
  • 2.4.2
  • 2.4.1
  • 2.4.0
  • 2.3.2
  • 2.3.1
  • 2.3
25 results

textarea.php

Blame
  • FormWithFields.php 4.72 KiB
    <?php
    
    namespace WPDesk\Forms\Form;
    
    use Psr\Container\ContainerInterface;
    use WPDesk\Forms\ContainerForm;
    use WPDesk\Forms\Field;
    use WPDesk\Forms\FieldProvider;
    use WPDesk\Forms\Form;
    use WPDesk\Persistence\Adapter\ArrayContainer;
    use WPDesk\Persistence\ElementNotExistsException;
    use WPDesk\Persistence\PersistentContainer;
    use WPDesk\View\Renderer\Renderer;
    
    class FormWithFields implements Form, ContainerForm, FieldProvider {
    	/**
    	 * Unique form_id.
    	 *
    	 * @var string
    	 */
    	protected $form_id = 'form';
    	/**
    	 * Updated data.
    	 *
    	 * @var array
    	 */
    	private $updated_data;
    	/**
    	 * Form fields.
    	 *
    	 * @var Field[]
    	 */
    	private $fields;
    
    	/**
    	 * FormWithFields constructor.
    	 *
    	 * @param array $fields Form fields.
    	 * @param string $form_id Unique form id.
    	 */
    	public function __construct( array $fields, $form_id = 'form' ) {
    		$this->fields       = $fields;
    		$this->form_id      = $form_id;
    		$this->updated_data = null;
    	}
    
    	/**
    	 * @inheritDoc
    	 */
    	public function is_submitted() {
    		return null !== $this->updated_data;
    	}
    
    	/**
    	 * @inheritDoc
    	 */
    	public function add_field( Field $field ) {
    		$this->fields[] = $field;
    	}
    
    	/**
    	 * @inheritDoc
    	 */
    	public function is_active() {
    		return true;
    	}
    
    	/**
    	 * Add more fields to form.
    	 *