<commit_before><?php

namespace Bootstrap\Components\AppzioUiKit\Forms;
use Bootstrap\Components\BootstrapComponent;

trait uiKitHintedTextField {

    /**
     * @param $content string, no support for line feeds
     * @param array $styles 'margin', 'padding', 'orientation', 'background', 'alignment', 'radius', 'opacity',
     * 'orientation', 'height', 'width', 'align', 'crop', 'text-style', 'font-size', 'text-color', 'border-color',
     * 'border-width', 'font-android', 'font-ios', 'background-color', 'background-image', 'background-size',
     * 'color', 'shadow-color', 'shadow-offset', 'shadow-radius', 'vertical-align', 'border-radius', 'text-align',
     * 'lazy', 'floating' (1), 'float' (right | left), 'max-height', 'white-space' (no-wrap), parent_style
     * @param array $parameters selected_state, variable, onclick, style
     * @return \stdClass
     */

    public function uiKitHintedTextField($hint,$variablename,$type='text', array $parameters=array(),array $styles=array()) {
        /** @var BootstrapComponent $this */

        $parameters['variable'] = $variablename;

        $title_params['style'] = 'uikit_steps_hint';
	    if ( isset($parameters['uppercase']) AND $parameters['uppercase'] ) {
	        $title_params['uppercase'] = true;
        }

        if($this->model->getValidationError($variablename)) {
            $error[] = $this->getComponentText($hint .' ', $title_params);
            $error[] = $this->getComponentText($this->model->getValidationError($variablename),array('style' => 'uikit_steps_error'));
            $out[] = $this->getComponentRow($error,array(),array('width' => '100%'));
        } else {
            $out[] = $this->getComponentText($hint, $title_params);
        }

        if(!isset($parameters['value'])){
            $val = $this->model->getSubmittedVariableByName($variablename) ? $this->model->getSubmittedVariableByName($variablename) : $this->model->getSavedVariable($variablename);
        } else {
            $val = $parameters['value'];
        }

        switch($type){
            case 'text':
                $out[] = $this->getComponentFormFieldText($val,
                    array_merge(array('style' => 'uikit_hinted_text'), $parameters)
                );
                break;

            case 'email':
                $parameters['input_type'] = 'email';
                $out[] = $this->getComponentFormFieldText($val,
                    array_merge(array('style' => 'uikit_hinted_text'), $parameters)
                );
                break;

            case 'phone':
                $parameters['input_type'] = 'phone';
                $out[] = $this->getComponentFormFieldText($val,
                    array_merge(array('style' => 'uikit_hinted_text'), $parameters)
                );
                break;

            case 'number':
                $parameters['input_type'] = 'number';
                $out[] = $this->getComponentFormFieldText($val,<commit_msg>making sure that value is always set<commit_after><?php

namespace Bootstrap\Components\AppzioUiKit\Forms;
use Bootstrap\Components\BootstrapComponent;

trait uiKitHintedTextField {

    /**
     * @param $content string, no support for line feeds
     * @param array $styles 'margin', 'padding', 'orientation', 'background', 'alignment', 'radius', 'opacity',
     * 'orientation', 'height', 'width', 'align', 'crop', 'text-style', 'font-size', 'text-color', 'border-color',
     * 'border-width', 'font-android', 'font-ios', 'background-color', 'background-image', 'background-size',
     * 'color', 'shadow-color', 'shadow-offset', 'shadow-radius', 'vertical-align', 'border-radius', 'text-align',
     * 'lazy', 'floating' (1), 'float' (right | left), 'max-height', 'white-space' (no-wrap), parent_style
     * @param array $parameters selected_state, variable, onclick, style
     * @return \stdClass
     */

    public function uiKitHintedTextField($hint,$variablename,$type='text', array $parameters=array(),array $styles=array()) {
        /** @var BootstrapComponent $this */

        $parameters['variable'] = $variablename;

        $title_params['style'] = 'uikit_steps_hint';
	    if ( isset($parameters['uppercase']) AND $parameters['uppercase'] ) {
	        $title_params['uppercase'] = true;
        }

        if($this->model->getValidationError($variablename)) {
            $error[] = $this->getComponentText($hint .' ', $title_params);
            $error[] = $this->getComponentText($this->model->getValidationError($variablename),array('style' => 'uikit_steps_error'));
            $out[] = $this->getComponentRow($error,array(),array('width' => '100%'));
        } else {
            $out[] = $this->getComponentText($hint, $title_params);
        }

        if(!isset($parameters['value'])){
            $val = $this->model->getSubmittedVariableByName($variablename) ? $this->model->getSubmittedVariableByName($variablename) : $this->model->getSavedVariable($variablename);
        } else {
            $val = $parameters['value'];
        }

        if(!$val){
            $val = $this->model->getSavedVariable($variablename);
        }

        switch($type){
            case 'text':
                $out[] = $this->getComponentFormFieldText($val,
                    array_merge(array('style' => 'uikit_hinted_text'), $parameters)
                );
                break;

            case 'email':
                $parameters['input_type'] = 'email';
                $out[] = $this->getComponentFormFieldText($val,
                    array_merge(array('style' => 'uikit_hinted_text'), $parameters)
                );
                break;

            case 'phone':
                $parameters['input_type'] = 'phone';
                $out[] = $this->getComponentFormFieldText($val,
                    array_merge(array('style' => 'uikit_hinted_text'), $parameters)
                );
                break;

            case 'number':
                $parameters['input_type'] = 'number';
                $out[] = $this->getComponentFormFieldText($val,
{'fraction_non_alphanumeric': 0.17038506032060816, 'fraction_numerical': 0.0013220955214014213, 'mean_word_length': 2.6924954240390484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4665008', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1677, 'n_words': 292}