<?php
/**
 * class presentation_edit_form
 *
 * Description for class presentation_edit_form
 *
 * @author:
*/
namespace form;

use form\slide_form;

class slide_extend_form extends slide_form {
	public function init() {
		$this->addElement("name", array("required"));
		$this->addElement("image", array("required"));
		$this->addElement("image_name", array("required"));
		$this->addElement("description", array("required"));
		$this->addElement("quantity", array("required"));
		$this->addElement("more_save", array("required"));
	}

	public function startData($currentData) {
		$data = array();
		
		$data["config"] = array(
			"image" => "",
			"image_name" => "",
			"description" => "",
			"quantity" => "3",
			"more_save" => "0"
			);
		$data["options"] = false;

		return $data;
	}

	public function save($board_id) {
		global $__database;

		$name = $this->getElement("name")->getValue();
		$image = $this->getElement("image")->getValue();
		$image_name = $this->getElement("image_name")->getValue();
		$description = $this->getElement("description")->getValue();
		$quantity = $this->getElement("quantity")->getValue();
		$more_save = $this->getElement("more_save")->getValue();

		if($more_save != "1") {
			$more_save = "0";
		}

		$config = array(
			"image" => $image,
			"image_name" => $image_name,
			"description" => $description,
			"quantity" => $quantity,
			"more_save" => $more_save
			);
		
		return $this->__save($board_id, $name, "", "", $config, array());
	}
}