/** * * - div : si vrai la valeur retournée sera contenu dans une div * - divright : si vrai le champ input sera retourné dans un div * - fulllabelerror : si vrai l'affichage du message d'erreur se fera à part * * @see FormHelper::input() */ function input($name, $label, $options = array()) { //==================== PARAMETRAGES ====================// $escapeAttributes = array('div', 'divright', 'fulllabelerror'); $this->escapeAttributes = am($escapeAttributes, $this->escapeAttributes); //Liste des options par défaut $defaultOptions = array('div' => true, 'divright' => true, 'fulllabelerror' => false); $options = array_merge($defaultOptions, $options); //Génération du tableau d'options utilisé dans la fonction $inputDatas = parent::input($name, $label, $options); //Appel fonction parente //==================== TRAITEMENTS DES DONNEES ====================// if ($inputDatas['inputOptions']['type'] == 'hidden') { return $inputDatas['inputElement']; } //Cas du champ caché $classError = ''; if (!empty($inputDatas['inputError'])) { $classError = ' error'; } if ($inputDatas['inputOptions']['div']) { if (isset($inputDatas['inputOptions']['divRowBorderTop']) && !$inputDatas['inputOptions']['divRowBorderTop']) { $styleDiv = ' style="border-top:none"'; } else { $styleDiv = ''; } if ($inputDatas['inputOptions']['divright']) { if ($inputDatas['inputOptions']['fulllabelerror']) { return '<div class="row' . $classError . '"' . $styleDiv . '>' . $inputDatas['inputLabel'] . '<div class="rowright">' . $inputDatas['inputElement'] . '</div>' . $inputDatas['inputError'] . '</div>'; } else { return '<div class="row' . $classError . '"' . $styleDiv . '>' . $inputDatas['inputLabel'] . '<div class="rowright">' . $inputDatas['inputElement'] . $inputDatas['inputError'] . '</div>' . '</div>'; } } else { return '<div class="row' . $classError . '"' . $styleDiv . '>' . $inputDatas['inputLabel'] . $inputDatas['inputElement'] . $inputDatas['inputError'] . '</div>'; } } else { return $inputDatas['inputLabel'] . $inputDatas['inputElement'] . $inputDatas['inputError']; } }
/** * * - div : si vrai la valeur retournée sera contenu dans une div * - divright : si vrai le champ input sera retourné dans un div * - fulllabelerror : si vrai l'affichage du message d'erreur se fera à part * @version 25/03/2015 by FI - Correction de la gestion du champ traduit pour tester l'exitence d'un model * @version 30/03/2015 by FI - Correction du test sur le champ traduit pour prendre en compte les noms de champs utilisants la notation . * * @see FormHelper::input() */ function input($name, $label, $options = array()) { //////////////////////// // PARAMETRAGES // $modelName = isset($this->view->controller->params['modelName']) ? $this->view->controller->params['modelName'] : ''; //Récupération du model courant $escapeAttributes = array('div', 'divright', 'fulllabelerror', 'colorpicker', 'inputDatas', 'divRowBorderTop', 'divRowCss'); $this->escapeAttributes = am($escapeAttributes, $this->escapeAttributes); /////////////////////////////// // GESTION DES OPTIONS // $defaultOptions = array('div' => true, 'divright' => true, 'fulllabelerror' => false, 'colorpicker' => false, 'onlyInput' => false, 'inputDatas' => false); $options = array_merge($defaultOptions, $options); //Génération du tableau d'options utilisé dans la fonction $htmlInput = ''; //Chaine de caractères qui va contenir l'élément input demandé //////////////////////////////////// // GESTION DES TRADUCTIONS // //On va contrôler si l'input à générer est "traductible" //On va prendre en compte les names utilisants la notation AAA.BBB.CCC et récupérer le dernier élément du tableau pour vérifier s'il est lui aussi présent dans la liste $explodeName = explode('.', $name); $translatedInput = isset($this->view->controller->{$modelName}) && !empty($modelName) && $this->view->controller->{$modelName}->fieldsToTranslate && in_array(end($explodeName), $this->view->controller->{$modelName}->fieldsToTranslate); //Input traduit if ($translatedInput) { $fieldsToTranslate = $this->view->controller->{$modelName}->fieldsToTranslate; $languages = Session::read('Backoffice.Languages'); foreach ($languages as $language) { $languageLabel = $label . ' <img src="' . $language['picture'] . '" style="float: left;margin-right: 5px;" />'; $inputDatas = parent::input($name . '.' . $language['code'], $languageLabel, am($options, array('divRowCss' => 'row_' . $language['code']))); //Appel fonction parente $htmlInput .= $this->_html_input($inputDatas); } //Cas général } else { $inputDatas = parent::input($name, $label, $options); //Appel fonction parente $htmlInput = $this->_html_input($inputDatas); } return $htmlInput; }