Modification du helper pour la session permet de charger les donnée enregistré en sessions.
This commit is contained in:
parent
ecdd442a46
commit
0412b58420
@ -10,32 +10,44 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
if($type == $field['type']) {
|
||||
switch($type){
|
||||
case 'select':
|
||||
return ($this->structureHTML($field['label'], $this->selectHTML($name, $field)));
|
||||
return ($this->structureHTML($field['label'], $this->selectHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'selectMultiple':
|
||||
return ($this->structureHTML($field['label'], $this->selectMultipleHTML($name, $field)));
|
||||
return ($this->structureHTML($field['label'], $this->selectMultipleHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'interval':
|
||||
return ($this->structureHTML($field['label'], $this->intervalHTML($name, $field)));
|
||||
return ($this->structureHTML($field['label'], $this->intervalHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'date':
|
||||
return ($this->structureHTML($field['label'], $this->dateHTML($name, $field)));
|
||||
return ($this->structureHTML($field['label'], $this->dateHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'text':
|
||||
return ($this->structureHTML($field['label'], $this->textHTML($name, $field)));
|
||||
return ($this->structureHTML($field['label'], $this->textHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'textarea':
|
||||
return ($this->structureHTML($field['label'], $this->textareaHTML($name, $field)));
|
||||
return ($this->structureHTML($field['label'], $this->textareaHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'radio':
|
||||
return ($this->structureHTML($field['label'], $this->radioHTML($name, $field)));
|
||||
return ($this->structureHTML($field['label'], $this->radioHTML($name, $field), $this->createValidate($type, $name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function structureHTML($label, $html)
|
||||
private function createValidate($type, $name)
|
||||
{
|
||||
switch($type) {
|
||||
case 'textarea':
|
||||
case 'date':
|
||||
$return = ('<a href="">Valider</a>');
|
||||
}
|
||||
$return .= ' <a href="">Switch de champ</a>';
|
||||
return ($return);
|
||||
}
|
||||
|
||||
private function structureHTML($label, $html, $lien = null)
|
||||
{
|
||||
$return ='<div class="fieldgrp">
|
||||
<label>'.$label.'</label>
|
||||
<div class="field">
|
||||
'.$html.'
|
||||
</div>
|
||||
<span>'.$lien.'</span>
|
||||
</div>';
|
||||
|
||||
return ($return);
|
||||
@ -43,12 +55,15 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Select */
|
||||
private function selectMultipleHTML($name, $field)
|
||||
{
|
||||
$i = 0;
|
||||
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<select class="criteres" name="'.$name.'">';
|
||||
$return .= '<option value="tous">Tous</option>';
|
||||
foreach($field['fields'][$field['type']]['value'] as $option) {
|
||||
$return .= '<option '.(($field['fields']['userValue'] == $option)?'selected':'').' value="'.$i++.'">'.$option.'</option>';
|
||||
foreach($field['fields'][$field['type']]['value'] as $value => $label) {
|
||||
$selected = "";
|
||||
if(($session->getCritere($name) != null) and $session->getCritere($name) == $value)
|
||||
$selected = " selected";
|
||||
$return .= '<option'.((!empty($selected))?$selected:null).' value="'.$value.'">'.$label.'</option>';
|
||||
}
|
||||
$return .= '</select>';
|
||||
return ($return);
|
||||
@ -57,12 +72,15 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Select Multiple */
|
||||
private function selectHTML($name, $field)
|
||||
{
|
||||
$i = 0;
|
||||
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<select class="criteres" name="'.$name.'">';
|
||||
$return .= '<option value="tous">Tous</option>';
|
||||
foreach($field['fields'][$field['type']]['value'] as $option) {
|
||||
$return .= '<option '.(($field['fields']['selected'] == $option)?'selected':'').' value="'.$i++.'">'.$option.'</option>';
|
||||
foreach($field['fields'][$field['type']]['value'] as $value => $label) {
|
||||
$selected = "";
|
||||
if(($session->getCritere($name) != null) and $session->getCritere($name) == $value)
|
||||
$selected = " selected";
|
||||
$return .= '<option'.((!empty($selected))?$selected:null).' value="'.$value.'">'.$label.'</option>';
|
||||
}
|
||||
$return .= '</select>';
|
||||
return ($return);
|
||||
@ -71,8 +89,10 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Interval */
|
||||
private function intervalHTML($name, $field)
|
||||
{
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<div class="mySlider" style="text-align:right;height:17px;">';
|
||||
$return .= '<input style="display:none;" value="'.$field['fields'][$field['type']]['value'][0].','.$field['fields'][$field['type']]['value'][1].'" name="'.$name.'" class="range slider_Text" type="text" id="'.$name.'" min="0" max="1000" />';
|
||||
$return .= '<input style="display:none;" value="'.$session->getCritere($name).'" name="'.$name.'" class="range slider_Text" type="text" id="'.$name.'" min="0" max="1000" />';
|
||||
$return .= '<div input="'.$name.'" class="slider-range"></div>';
|
||||
|
||||
return ($return);
|
||||
@ -81,7 +101,9 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Dates */
|
||||
private function dateHTML($name, $field)
|
||||
{
|
||||
$return = '<input value="" type="text" class="datepicker" name="'.$name.'1" /> a ';
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<input value="'.$session->getCritere($name).'" type="text" class="datepicker" name="'.$name.'1" /> a ';
|
||||
$return .= '<input type="text" class="datepicker" name="'.$name.'2" />';
|
||||
|
||||
return ($return);
|
||||
@ -90,7 +112,9 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Textes */
|
||||
private function textHTML($name, $field)
|
||||
{
|
||||
$return = '<input style="border:1px inset silver;width:60%" class="criteres" type="text" name="'.$name.'" value="'.$field['fields'][$field['type']]['value'].'" />';
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<input style="border:1px inset silver;width:60%" class="criteres" type="text" name="'.$name.'" value="'.$session->getCritere($name).'" />';
|
||||
|
||||
return ($return);
|
||||
}
|
||||
@ -98,7 +122,9 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Textarea */
|
||||
private function textareaHTML($name, $field)
|
||||
{
|
||||
$return = '<textarea name="'.$name.'">'.$field['fields'][$field['type']]['value'].'</textarea>';
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<textarea name="'.$name.'">'.$session->getCritere($name).'</textarea>';
|
||||
|
||||
return ($return);
|
||||
}
|
||||
@ -106,6 +132,8 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Radios */
|
||||
private function radioHTML($name, $field, $item)
|
||||
{
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<input type="radio" name="'.$name.'" />';
|
||||
|
||||
return ($return);
|
||||
|
Loading…
Reference in New Issue
Block a user