Skip to content
Snippets Groups Projects
Select Git revision
  • cf9cae0e69be553e649ece4f8dc36ac2f73aecb3
  • 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

BasicField.php

Blame
  • BasicField.php 5.89 KiB
    <?php
    
    namespace WPDesk\Forms\Field;
    
    use WPDesk\Forms\Field;
    use WPDesk\Forms\Sanitizer\NoSanitize;
    use WPDesk\Forms\Serializer;
    use WPDesk\Forms\Serializer\NoSerialize;
    use WPDesk\Forms\Validator\ChainValidator;
    use WPDesk\Forms\Validator\RequiredValidator;
    
    /**
     * Base class for fields. Is responsible for settings all required field values and provides standard implementation for
     * the field interface.
     *
     * @package WPDesk\Forms
     */
    abstract class BasicField implements Field {
    	use Field\Traits\HtmlAttributes;
    
    	/** @var array[] */
    	protected $meta;
    
    	protected $default_value;
    
    	public function __construct() {
    		$this->meta['class'] = [];
    	}
    
    	public function get_label() {
    		return $this->meta['label'];
    	}
    
    	/**
    	 * @param string $value
    	 *
    	 * @return $this
    	 */
    	public function set_label( $value ) {
    		$this->meta['label'] = $value;
    
    		return $this;
    	}
    
    	public function get_description_tip() {
    		return $this->meta['description_tip'];
    	}
    
    	public function has_description_tip() {
    		return isset( $this->meta['description_tip'] );
    	}
    
    	public function should_override_form_template() {
    		return isset( $this->attributes['overrite_template'] ) ? $this->attributes['overrite_template'] : false;
    	}
    
    	public function get_description() {
    		return $this->meta['description'];
    	}
    
    	public function has_label() {
    		return isset( $this->meta['label'] );
    	}
    
    	public function has_description() {
    		return isset( $this->meta['description'] );
    	}
    
    	public function set_description( $value ) {
    		$this->meta['description'] = $value;