Skip to content
Snippets Groups Projects
Commit 1e0500d4 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #14218 fix datepicker form elements

parent 425476f8
Branches
Tags
3 merge requests!390Dev #14218 add custom fields to articles,!386Dev #14218 add custom fields to articles,!385Dev #14218 add custom fields to articles
......@@ -25,7 +25,9 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form {
$form = parent::newWith($datas, $custom_form);
$form
->addAuthorFullName(isset($datas['id_user']) ? $datas['id_user'] : 0)
->addWorkflow(isset($datas['status']) ? $datas['status'] : '' );
->addWorkflow(isset($datas['status']) ? $datas['status'] : '' )
->addAgenda($datas['all_day'])
;
return $form;
}
......@@ -46,24 +48,31 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form {
'order' => 3])
->addElement('comboCategories', 'id_cat', ['label' => $this->_('Catégorie'),
'order' => 4])
->addElement('datePicker', 'debut', ['label' => 'Publication du',
'size' => 10,
'allowEmpty' => false,
'order' => 7])
->addElement('datePicker', 'fin', ['label' => 'au', 'size' => 10 ,
'order' => 8])
'order' => 8])
->addElement('datePicker', 'events_debut', ['label' => 'Agenda du',
'size' => 10,
'allowEmpty' => false ,
'date_only' => false,
'order' => 9])
'dateOnly' => false,
'order' => 9,
'toggleAllDay' => 'all_day'])
->addElement('datePicker', 'events_fin', ['label' => 'au',
'size' => 10 ,
'date_only' => false,
'order' => 10])
'dateOnly' => false,
'order' => 10,
'toggleAllDay' => 'all_day'])
->addElement('checkbox', 'all_day',
['label' => $this->_("L'évenement dure toute la journée"),
'order' => 11])
'order' => 11])
->addElement('select', 'id_lieu', ['label' => $this->_('Lieu'),
'multiOptions' => $this->getLocations(),
'order' => 12])
......@@ -118,6 +127,16 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form {
}
protected function addAgenda($all_day) {
if (!$all_day)
return $this;
$this->events_debut->setDateOnly(true);
$this->events_fin->setDateOnly(true);
return $this;
}
protected function addWorkflow($status) {
if(!Class_AdminVar::isWorkFlowEnabled())
return $this;
......@@ -134,7 +153,8 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form {
['order' => 6,
'cols' => 45,
'rows' => 5,
'style' => 'display:none']);
'style' => 'display:none',
'placeholder' => $this->_('Message d\'explication du refus.')]);
$this->getElement('refus_message')->addDecorator('JqueryReady', ['script' => $this->getRejectCommentScript()]);
$status = $this->getElement('status');
......@@ -161,7 +181,7 @@ class ZendAfi_Form_Admin_News extends ZendAfi_Form {
protected function getLocations() {
return array_merge(['0' => $this->_('Aucun')], Class_Lieu::getAllLibelles());
return ['0' => $this->_('Aucun')] + Class_Lieu::getAllLibelles();
}
......
......@@ -27,7 +27,8 @@ class ZendAfi_Form_Decorator_DatePicker extends Zend_Form_Decorator_Abstract {
return $content
.$this->_element->getView()->datePicker($this->_element->getName(),
$this->_element->getValue(),
$this->_element->getDateOnly());
$this->_element->getDateOnly(),
$this->_element->getToggleAllDay());
}
}
?>
\ No newline at end of file
......@@ -19,14 +19,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Form_Element_DatePicker extends Zend_Form_Element_Xhtml {
protected $_date_min, $_date_max, $_name, $_date_only;
protected $_date_min, $_date_max, $_name, $_date_only = true, $_toggle_all_day;
public function __construct($spec, $options = null) {
parent::__construct($spec, $options);
$this->_date_only = isset($options['date_only']) ? $options['date_only'] : true ;
$decorators = $this->_decorators;
$this->_decorators = array('DatePicker' => new ZendAfi_Form_Decorator_DatePicker());
$this->_decorators = ['DatePicker' => new ZendAfi_Form_Decorator_DatePicker()];
foreach ($decorators as $name => $value) {
$this->_decorators[$name] = $value;
......@@ -75,8 +74,25 @@ class ZendAfi_Form_Element_DatePicker extends Zend_Form_Element_Xhtml {
}
public function setDateOnly($flag) {
$this->_date_only = $flag;
return $this;
}
public function getDateOnly() {
return $this->_date_only;
}
public function setToggleAllDay($name) {
$this->_toggle_all_day = $name;
return $this;
}
public function getToggleAllDay() {
return $this->_toggle_all_day;
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment