<?php

/**
 * Description of Group
 *
 * @author Arkadiusz Rychlik <a.rychlik at eppe.com.pl>
 */
class Newsletter_Form_Admin_Group extends Main_Newsletter_Form_Admin_Group {

	public function init() {
		$exclude_id = $this->bean ? $this->bean->id : NULL;

		$name = new Zend_Form_Element_Text('name', [
			'label' => 'Nazwa',
			'required' => true,
			'validators' => [
				new Eppe_Validate_StringLength(['min' => 4, 'max' => 20]),
				new Eppe_Validate_Db_NoRecordExists(['bean' => 'nlgroup', 'column' => 'name', 'exclude_id' => $exclude_id])
			],
			'filters' => [
				new Zend_Filter_StringTrim()
			]
		]);

		$this->addElement($name);
		
		$this->addToolbar();
	}
}
