Initializes the form field.

@throws \LogicException When node type is incorrect
770021
protected function initialize()
    {
        if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) {
            throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName));
        }

        if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) {
            throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type')));
        }

        $this->value = null;
        $this->options = [];
        $this->multiple = false;

        if ('input' == $this->node->nodeName) {
            $this->type = strtolower($this->node->getAttribute('type'));
            $optionValue = $this->buildOptionValue($this->node);
            $this->options[] = $optionValue;

            if ($this->node->hasAttribute('checked')) {
                $this->value = $optionValue['value'];
            }
        } else {
            $this->type = 'select';
            if ($this->node->hasAttribute('multiple')) {
                $this->multiple = true;
                $this->value = [];
                $this->name = str_replace('[]', '', $this->name);
            }

            $found = false;
            foreach ($this->xpath->query('descendant::option', $this->node) as $option) {
                $optionValue = $this->buildOptionValue($option);
                $this->options[] = $optionValue;

                if ($option->hasAttribute('selected')) {
                    $found = true;
                    if ($this->multiple) {
                        $this->value[] = $optionValue['value'];
                    } else {
                        $this->value = $optionValue['value'];
                    }
                }
            }

            // if no option is selected and if it is a simple select box, take the first option as the value
            if (!$found && !$this->multiple && !empty($this->options)) {
                $this->value = $this->options[0]['value'];
            }
        }
    }
1019386
protected function initialize()
    {
        $this->schemaDomainMap = array();
        foreach (PropelTypes::getPropelTypes() as $type) {
            $this->schemaDomainMap[$type] = new Domain($type);
        }
        // BU_* no longer needed, so map these to the DATE/TIMESTAMP domains
        $this->schemaDomainMap[PropelTypes::BU_DATE] = new Domain(PropelTypes::DATE);
        $this->schemaDomainMap[PropelTypes::BU_TIMESTAMP] = new Domain(PropelTypes::TIMESTAMP);

        // Boolean is a bit special, since typically it must be mapped to INT type.
        $this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain(PropelTypes::BOOLEAN, "INTEGER");
    }
237885
public void writeInitField()
    {
        Record recLogicFile = this.getRecord(LogicFile.LOGIC_FILE_FILE);
        try   {
            String strClassName;
            Record recClassInfo = this.getMainRecord();
            FieldData recFieldData = (FieldData)this.getRecord(FieldData.FIELD_DATA_FILE);
            strClassName = recClassInfo.getField(ClassInfo.CLASS_NAME).getString();
            if (this.readThisMethod("initField"))
                this.writeThisMethod(CodeType.THICK);
            else
            {
                String strInitField = this.getInitField(recFieldData, false, false);
                if (strInitField.length() != 0)
                {
                    recLogicFile.getField(LogicFile.METHOD_NAME).setString("initField");
                    recLogicFile.setKeyArea(LogicFile.METHOD_CLASS_NAME_KEY);
                    if (!recLogicFile.seek("="))
                    {
                        this.writeMethodInterface(null, "initField", "int", "boolean displayOption", "", "Initialize the field.", null);
                        String setOp = ".setString";
                        if ((strInitField.equalsIgnoreCase("todaysDate()")) || (strInitField.equalsIgnoreCase("currentTime()")) || (strInitField.equalsIgnoreCase("getUserID()")))
                            setOp = ".setValue";
                        if (strInitField.length() > 0)
                            if ((strInitField.charAt(0) == 'k') ||
                                (Character.isDigit(strInitField.charAt(0))) ||
                                (strInitField.indexOf(".k") != -1))
                            setOp = ".setValue";
                        if ((strInitField.equals("true")) || (strInitField.equals("false")))
                            setOp = ".setState";
                        if ((strClassName.equalsIgnoreCase("IntegerField"))   //**Change this to look through the base classes for NumberField
                            || (strClassName.equalsIgnoreCase("ShortField"))
                            || (strClassName.equalsIgnoreCase("FloatField"))
                            || (strClassName.equalsIgnoreCase("RealField"))
                            || (strClassName.equalsIgnoreCase("CurrencysField"))
                            || (strClassName.equalsIgnoreCase("DoubleField")))
                                setOp = ".setValue";
                        if (strInitField.equals("all"))
                        {
                            strInitField = "\"all\""; // HACK
                            setOp = ".setString";
                        }
                        if ((strInitField.indexOf('_') != -1) && (strInitField.indexOf('.') == -1))
                        {
                            strInitField = "\"\"/**" + strInitField + "*/";   // HACK
                            setOp = ".setString";
                        }
                        if (strInitField != strClassName)
                            m_StreamOut.writeit("\treturn this" + setOp + "(" + strInitField + ", displayOption, DBConstants.INIT_MOVE);\n");
                        m_StreamOut.writeit("}\n");
                    }
                }
            }
        } catch (DBException ex)    {
            ex.printStackTrace();
        } finally {
            recLogicFile.setKeyArea(LogicFile.SEQUENCE_KEY);   // set this back
        }
    }
129932
final function onFormInitialized() {
		parent::onFormInitialized();
		$this->addClass('df-number');
		df_fe_init($this, __CLASS__);
		$this->setAfterElementHtml($this[self::LABEL_RIGHT]);
	}
558311
public function init()
    {
        $children = array();
        foreach ($this->children as $child_widget) {
            $children[] = $this->remove($child_widget);
        }

        $field = new SwatFormField();
        $field->id = $field->getUniqueId();
        $prototype_id = $field->id;

        foreach ($children as $child_widget) {
            $field->add($child_widget);
        }

        $this->add($field);

        parent::init();

        foreach ($this->replicators as $id => $title) {
            $field = $this->getWidget($prototype_id, $id);
            $field->title = $title;
        }
    }
1214995
private function _initialize()
    {
        $params = $this->getParameters();
        if ($params !== null) {
            for ($i = 0, $_i = count($params); $i < $_i; $i++) {
                if ($params[$i]->getType() === null) {
                    if ($params[$i]->getName() === "style") {
                        $this->setStyle($params[$i]->getValue());
                    }
                } elseif ($params[$i]->getType() == "param") {
                    $xp = new XsltParam();
                    $xp->setName($params[$i]->getName());
                    $xp->setExpression($params[$i]->getValue());
                    $this->xsltParams[] = $xp;
                }
            }
        }
    }
397793
private function Initialize()
    {
        if (!$this->initialized)
        {
            $schema = $this->GetSchema();
            $t = $schema->Table();
            $sql = $schema->SqlBuilder();
           
            $what = $t->ToSelectList();
            $where = $sql->Equals($t->Field($schema->KeyField()), $sql->Value($this->KeyValue()));
            $select = $sql->Select(false, $what, $t, $where);
            $reader = $schema->Connection()->ExecuteQuery((string)$select);
            if ($reader->Read())
                $this->InitFromReader($reader);

            $reader->Close();
        }
    }
74233
protected function initForm()
    {
        $name = isset($this->options['name']) ? $this->options['name'] : '';
        if(empty($name)){
            $name = 'form_'.(count(self::$forms)+1);
        }
        unset($this->options['name']);

        $this->form = tao_helpers_form_FormFactory::getForm($name, $this->options);

        //add translate action in toolbar
        $actions = tao_helpers_form_FormFactory::getCommonActions();

        //add a hidden form element that states that it is an Instance Form.
        $instanceElt = tao_helpers_form_FormFactory::getElement('tao.forms.instance', 'Hidden');
        $instanceElt->setValue('1');
        $this->form->addElement($instanceElt, true);

        //add a token to protect against xsrf
        $tokenElt = tao_helpers_form_FormFactory::getElement('token', 'Token');
        $tokenElt->addValidator(new XsrfTokenValidator());
        $this->form->addElement($tokenElt, true);

        $this->form->setActions($actions, 'top');
        $this->form->setActions($actions, 'bottom');
    }
991744
public function init()
    {
        if ($this->form !== null && !$this->form instanceof ActiveForm) {
            throw new InvalidConfigException('Property "form" must be an instance of yii\widgets\ActiveForm');
        }

        if ($this->showGeneralError && $this->field === null) {
            $this->showGeneralError = false;
        }

        $this->guessColumns();
        $this->initData();

        parent::init();
    }
832259
protected function initializeNodeTemplates()
    {
        $this->nodeType = $this->nodeTypeManager->getNodeType($this->nodeTypeName);
        $this->nodeTemplate = new NodeTemplate();
        $this->nodeTemplate->setNodeType($this->nodeType);
    }
762895
public function init()
    {
        if (!$this->model) {
            throw new CException('Parameter "model" should be provided for EditableField');
        }

        if (!$this->attribute) {
            throw new CException('Parameter "attribute" should be provided for EditableField');
        }

        $originalModel = $this->model;
        $originalAttribute = $this->attribute;
        $originalText = strlen($this->text) ? $this->text : CHtml::value($this->model, $this->attribute);

        //if apply set manually to false --> just render text, no js plugin applied
        if($this->apply === false) {
            $this->text = $originalText;
        } else {
            $this->apply = true;
        }

        //try to resolve related model (if attribute contains '.')
        $resolved = $this->resolveModels($this->model, $this->attribute);
        $this->model = $resolved['model'];
        $this->attribute = $resolved['attribute'];
        $this->staticModel = $resolved['staticModel'];
        $staticModel = $this->staticModel;
        $isMongo = $resolved['isMongo'];
        $isFormModel = $this->model instanceOf CFormModel;
        
        //if real (related) model not exists --> just print text
        if(!$this->model) {
        	$this->apply = false;
        	$this->text = $originalText;
		}
        
        
        //for security reason only safe attributes can be editable (e.g. defined in rules of model)
        //just print text (see 'run' method)
        if (!$staticModel->isAttributeSafe($this->attribute)) {
            $this->apply = false;
            $this->text = $originalText;
        }
        
        /*
         try to detect type from metadata if not set
        */
        if ($this->type === null) {
            $this->type = 'text';
            if (!$isMongo && !$isFormModel && array_key_exists($this->attribute, $staticModel->tableSchema->columns)) {
                $dbType = $staticModel->tableSchema->columns[$this->attribute]->dbType;
                if($dbType == 'date') {
                    $this->type = 'date';
                }
                if($dbType == 'datetime') {
                    $this->type = 'datetime';
                }
                if(stripos($dbType, 'text') !== false) {
                    $this->type = 'textarea';
                }
            }
        }

        //name
        if(empty($this->name)) {
            $this->name = $isMongo ? $originalAttribute : $this->attribute;
        }
        
        //pk (for mongo takes pk from parent!)
        $pkModel = $isMongo ? $originalModel : $this->model; 
        if(!$isFormModel) {
            if($pkModel && !$pkModel->isNewRecord) {
                $this->pk = $pkModel->primaryKey;
            }
        } else {
            //formModel does not have pk, so set `send` option to `always` (send without pk)
            if(empty($this->send) && empty($this->options['send'])) {
                $this->send = 'always';
            }
        }      
        
        parent::init();        
        
        /*
         If text not defined, generate it from model attribute for types except lists ('select', 'checklist' etc)
         For lists keep it empty to apply autotext.
         $this->_prepareToAutotext calculated in parent class Editable.php
        */
        if (!strlen($this->text) && !$this->_prepareToAutotext) {
            $this->text = $originalText;
        }
        
        //set value directly for autotext generation
        if($this->model && $this->_prepareToAutotext) {
            $this->value = CHtml::value($this->model, $this->attribute); 
        }
        
        //generate title from attribute label
        if ($this->title === null) {
            $titles = array(
              'Select' => array('select', 'date'),
              'Check' => array('checklist')
            );
            $title = Yii::t('EditableField.editable', 'Enter');
            foreach($titles as $t => $types) {
                if(in_array($this->type, $types)) {
                   $title = Yii::t('EditableField.editable', $t);
                }
            }
            $this->title = $title . ' ' . $staticModel->getAttributeLabel($this->attribute);
        } else {
            $this->title = strtr($this->title, array('{label}' => $staticModel->getAttributeLabel($this->attribute)));
        }
        
        //scenario
        if($pkModel && !isset($this->params['scenario'])) {
            $this->params['scenario'] = $pkModel->getScenario(); 
        }        
    }
561663
protected function InitForm()
    {
        $this->repeater = $this->LoadElement();
        $this->AddCssClassField();
        $this->AddCssIDField();
        $this->AddTemplateField();
        $this->AddSubmit();
    }
593374
private function InitForm()
    {
        $this->AddCategoryField();
        $this->AddTitleField();
        $this->AddTeaserField();
        $this->AddTextField();
        $this->AddPublishField();
        $this->AddPublishFromDateField();
        $this->AddPublishFromHourField();
        $this->AddPublishFromMinuteField();
        $this->AddPublishToDateField();
        $this->AddPublishToHourField();
        $this->AddPublishToMinuteField();
        $this->AddAuthorField();
        $this->AddSubmit();
    }
1057693
public function init()
	{
		if (!isset($this->form))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Form is not set.');

		if (!isset($this->model))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Model is not set.');

		if (!isset($this->type))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Input type is not set.');

		if ($this->type === self::TYPE_UNEDITABLE)
		{
			if (isset($this->htmlOptions['class']))
				$this->htmlOptions['class'] .= ' uneditable-input';
			else
				$this->htmlOptions['class'] = 'uneditable-input';
		}

		$this->processHtmlOptions();
	}
332839
public function postInit()
    {
        foreach ($this->elements as $x => $field) {
            if ($field instanceof Form_Field) {
                $field->set($this->recall($x));

                if ($field->no_save || !$field->get()) {
                    continue;
                }

                // also apply the condition
                if ($this->view->model && $this->view->model->hasElement($x)) {

                    // take advantage of field normalization
                    $this->view->model->addCondition($x, $field->get());
                }
            }
        }

        // call applyFilter hook if such exist, pass model of associated view as parameter
        $this->hook('applyFilter', array($this->view->model));
    }
443877
private function initialize()
    {
        $this->entity = '';
        $this->source = '';
        $this->mode = self::RSMODE_NOTCONNECTED;
        $this->result = null;
        $this->originalValues = null;
        $this->datafields = [];
        $this->values = [];
        $this->idFields = [];
    }
666086
protected function initForm()
    {
		$this->form = \tao_helpers_form_FormFactory::getForm('roleDebug');
		
		$action = \tao_helpers_form_FormFactory::getElement('save', 'Free');
		$action->setValue('<button class="btn-info form-submiter" type="button" id="addButton"><span class="icon-tools"></span>'.__('Restrict').'</button>');
		
		
		$this->form->setActions(array(), 'top');
		$this->form->setActions(array($action), 'bottom');
    }