Skip to content
Snippets Groups Projects
Select Git revision
  • 82b8ba8deeb55bfee8264e9d1489af16ee9ff42d
  • main default protected
  • devel
  • 1.0.0
4 results

HTMLDecorator.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;