2011-01-21 00:30:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
public function init()
|
|
|
|
{
|
2012-11-27 23:11:29 +01:00
|
|
|
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
2012-07-11 00:55:44 +02:00
|
|
|
// retrieves the length limit for each char field
|
|
|
|
// and store to assoc array
|
|
|
|
$maxLens = Application_Model_Show::getMaxLengths();
|
|
|
|
|
2011-04-12 06:14:26 +02:00
|
|
|
// Hidden element to indicate whether the show is new or
|
|
|
|
// whether we are updating an existing show.
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('hidden', 'add_show_id', [
|
|
|
|
'decorators' => ['ViewHelper'],
|
|
|
|
]);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-04-12 17:54:51 +02:00
|
|
|
// Hidden element to indicate the instance id of the show
|
|
|
|
// being edited.
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('hidden', 'add_show_instance_id', [
|
|
|
|
'decorators' => ['ViewHelper'],
|
|
|
|
]);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-01-21 00:30:53 +01:00
|
|
|
// Add name element
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('text', 'add_show_name', [
|
|
|
|
'label' => _('Name:'),
|
|
|
|
'class' => 'input_text',
|
|
|
|
'required' => true,
|
|
|
|
'filters' => ['StringTrim'],
|
|
|
|
'value' => _('Untitled Show'),
|
|
|
|
'validators' => [$notEmptyValidator, ['StringLength', false, [0, $maxLens['name']]]],
|
|
|
|
]);
|
2011-01-21 00:30:53 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// Add URL element
|
|
|
|
$this->addElement('text', 'add_show_url', [
|
|
|
|
'label' => _('URL:'),
|
|
|
|
'class' => 'input_text',
|
|
|
|
'required' => false,
|
|
|
|
'filters' => ['StringTrim'],
|
|
|
|
'validators' => [$notEmptyValidator, ['StringLength', false, [0, $maxLens['url']]]],
|
|
|
|
]);
|
2017-03-10 16:20:44 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// Add genre element
|
|
|
|
$this->addElement('text', 'add_show_genre', [
|
|
|
|
'label' => _('Genre:'),
|
|
|
|
'class' => 'input_text',
|
|
|
|
'required' => false,
|
|
|
|
'filters' => ['StringTrim'],
|
|
|
|
'validators' => [['StringLength', false, [0, $maxLens['genre']]]],
|
|
|
|
]);
|
2011-01-28 23:37:31 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// Add the description element
|
|
|
|
$this->addElement('textarea', 'add_show_description', [
|
|
|
|
'label' => _('Description:'),
|
|
|
|
'required' => false,
|
|
|
|
'class' => 'input_text_area',
|
|
|
|
'validators' => [['StringLength', false, [0, $maxLens['description']]]],
|
|
|
|
]);
|
2011-01-21 00:30:53 +01:00
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
$descText = $this->getElement('add_show_description');
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$descText->setDecorators([['ViewScript', [
|
2011-01-31 02:11:18 +01:00
|
|
|
'viewScript' => 'form/add-show-block.phtml',
|
2021-10-11 16:10:47 +02:00
|
|
|
'class' => 'block-display',
|
|
|
|
]]]);
|
|
|
|
|
2014-09-19 18:55:02 +02:00
|
|
|
// Add the instance description
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('textarea', 'add_show_instance_description', [
|
|
|
|
'label' => _('Instance Description:'),
|
|
|
|
'required' => false,
|
|
|
|
'class' => 'input_text_area',
|
|
|
|
'validators' => [['StringLength', false, [0, $maxLens['description']]]],
|
|
|
|
]);
|
|
|
|
|
2014-09-19 18:55:02 +02:00
|
|
|
$instanceDesc = $this->getElement('add_show_instance_description');
|
2017-03-10 16:20:44 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$instanceDesc->setDecorators([['ViewScript', [
|
|
|
|
'viewScript' => 'form/add-show-block.phtml',
|
|
|
|
'class' => 'block-display',
|
|
|
|
]]]);
|
|
|
|
$instanceDesc->setAttrib('disabled', 'disabled');
|
2014-09-19 18:55:02 +02:00
|
|
|
}
|
2017-02-13 15:35:09 +01:00
|
|
|
|
2017-03-10 16:20:44 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Enable the instance description when editing a show instance.
|
2014-09-19 18:55:02 +02:00
|
|
|
*/
|
|
|
|
public function enableInstanceDesc()
|
|
|
|
{
|
2017-03-10 16:20:44 +01:00
|
|
|
$el = $this->getElement('add_show_instance_description');
|
|
|
|
Logging::info($el);
|
|
|
|
$el->setAttrib('disabled', null);
|
|
|
|
$el->setAttrib('readonly', null);
|
2011-01-21 00:30:53 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function disable()
|
|
|
|
{
|
2012-03-30 21:11:24 +02:00
|
|
|
$elements = $this->getElements();
|
2012-08-29 05:04:55 +02:00
|
|
|
foreach ($elements as $element) {
|
|
|
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
2021-10-11 16:10:47 +02:00
|
|
|
$element->setAttrib('disabled', 'disabled');
|
2012-03-30 21:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-13 18:13:58 +01:00
|
|
|
|
|
|
|
public function makeReadonly()
|
|
|
|
{
|
|
|
|
$elements = $this->getElements();
|
|
|
|
foreach ($elements as $element) {
|
|
|
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
2021-10-11 16:10:47 +02:00
|
|
|
$element->setAttrib('readonly', 'readonly');
|
2013-12-13 18:13:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
}
|