<?php

namespace Engine\Form\Input;


/**
 * The class manages a field which supports an unlimited list of text fields.
 * @author Gabi
 */
class Cloned_Text extends \Engine\Form\Input\Text
{
	protected $class = "clonedText";

	public function __construct($label=null, $name=null, $value=null)
	{
		parent::__construct($label, $name, $value);

		$this->settings['minItems'] = 1;

		$this->settings['operations'] = [];
		$this->settings['operations']['add'] = true;
		$this->settings['operations']['remove'] = true;
		# $this->settings['operations']['default'] = true;
	}

	/**
	 * (non-PHPdoc)
	 * @see \Engine\Form\Input\ElementAbstract::setValue()
	 */
	public function setValue($value)
	{
		// this is the same as the basic setValue function, because i need to override the autocomplete's version
		if(!is_array($value)){
			$value = [];
		}

		$this->value = $value;
		return $this;
	}

}
