Initialize the form elements

@access protected
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
485516
protected function initElements()
    {
        
        $property = $this->getPropertyInstance();

	    $index = $this->getIndex();

	    $propertyProperties = array_merge(
			tao_helpers_form_GenerisFormFactory::getDefaultProperties(), 
			array(new core_kernel_classes_Property(GenerisRdf::PROPERTY_IS_LG_DEPENDENT),
                new core_kernel_classes_Property(TaoOntology::PROPERTY_GUI_ORDER),
                $this->getProperty(ValidationRuleRegistry::PROPERTY_VALIDATION_RULE)
			)
		);
	    $values = $property->getPropertiesValues($propertyProperties);
    	
    	$elementNames = array();
		foreach($propertyProperties as $propertyProperty){
		
			//map properties widgets to form elements
			$element = tao_helpers_form_GenerisFormFactory::elementMap($propertyProperty);
			
			if(!is_null($element)){
				//take property values to populate the form
				if (isset($values[$propertyProperty->getUri()])) {
				    $propertyValues = $values[$propertyProperty->getUri()];
				    foreach($propertyValues as $value){
				        if(!is_null($value)){
				            if($value instanceof core_kernel_classes_Resource){
				                $element->setValue($value->getUri());
				            }
				            if($value instanceof core_kernel_classes_Literal){
				                $element->setValue((string)$value);
				            }
				        }
				    }
				}
				$element->setName("{$index}_{$element->getName()}");
                $element->addClass('property');

                if ($propertyProperty->getUri() == TaoOntology::PROPERTY_GUI_ORDER){
                    $element->addValidator(tao_helpers_form_FormFactory::getValidator('Integer'));
                }
                if ($propertyProperty->getUri() == OntologyRdfs::RDFS_LABEL){
                    $element->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
                }
				$this->form->addElement($element);
				$elementNames[] = $element->getName();
			}
		}
		
		//build the type list from the "widget/range to type" map
		$typeElt = tao_helpers_form_FormFactory::getElement("{$index}_type", 'Combobox');
		$typeElt->setDescription(__('Type'));
		$typeElt->addAttribute('class', 'property-type property');
		$typeElt->setEmptyOption(' --- '.__('select').' --- ');
		$options = array();
		$checkRange = false;
		foreach(tao_helpers_form_GenerisFormFactory::getPropertyMap() as $typeKey => $map){
			$options[$typeKey] = $map['title'];
            $widget = $property->getWidget();
			if($widget instanceof core_kernel_classes_Resource) {
				if($widget->getUri() == $map['widget']){
					$typeElt->setValue($typeKey);
					$checkRange = is_null($map['range']);
				}
			}
		}
		$typeElt->setOptions($options);
		$this->form->addElement($typeElt);
		$elementNames[] = $typeElt->getName();

	    $range = $property->getRange();

	    $rangeSelect = tao_helpers_form_FormFactory::getElement( "{$this->getIndex()}_range", 'Combobox' );
	    $rangeSelect->setDescription( __( 'List values' ) );
	    $rangeSelect->addAttribute( 'class', 'property-listvalues property' );
	    $rangeSelect->setEmptyOption( ' --- ' . __( 'select' ) . ' --- ' );

	    if ($checkRange) {
		    $rangeSelect->addValidator( tao_helpers_form_FormFactory::getValidator( 'NotEmpty' ) );
	    }

	    $this->form->addElement($rangeSelect);
	    $elementNames[] = $rangeSelect->getName();

	    //list drop down
	    $listElt = $this->getListElement( $range );
		$this->form->addElement($listElt);
		$elementNames[] = $listElt->getName();

	    //trees dropdown
	    $treeElt = $this->getTreeElement( $range );
	    $this->form->addElement($treeElt);
	    $elementNames[] = $treeElt->getName();

	    //index part
        $indexes = $property->getPropertyValues(new \core_kernel_classes_Property(OntologyIndex::PROPERTY_INDEX));
        foreach($indexes as $i => $indexUri){
            $indexProperty = new OntologyIndex($indexUri);
            $indexFormContainer = new tao_actions_form_IndexProperty($indexProperty,$index.$i);
            /** @var tao_helpers_form_Form $indexForm */
            $indexForm = $indexFormContainer->getForm();
            foreach($indexForm->getElements() as $element){
                $this->form->addElement($element);
                $elementNames[] = $element->getName();
            }
        }

        //add this element only when the property is defined (type)
        if(!is_null($property->getRange())){
            $addIndexElt = tao_helpers_form_FormFactory::getElement("index_{$index}_add", 'Free');
            $addIndexElt->setValue(
                "<a href='#' class='btn-info index-adder small index'><span class='icon-add'></span> " . __(
                    'Add index'
                ) . "</a><div class='clearfix'></div>"
            );
            $this->form->addElement($addIndexElt);
            $elementNames[] = $addIndexElt;
        }
        else{
            $addIndexElt = tao_helpers_form_FormFactory::getElement("index_{$index}_p", 'Free');
            $addIndexElt->setValue(
                "<p class='index' >" . __(
                    'Choose a type for your property first'
                ) . "</p>"
            );
            $this->form->addElement($addIndexElt);
            $elementNames[] = $addIndexElt;
        }

        //add an hidden elt for the property uri
        $encodedUri = tao_helpers_Uri::encode($property->getUri());
        $propUriElt = tao_helpers_form_FormFactory::getElement("{$index}_uri", 'Hidden');
        $propUriElt->addAttribute('class', 'property-uri property');
        $propUriElt->setValue($encodedUri);
        $this->form->addElement($propUriElt);
        $elementNames[] = $propUriElt;

		if(count($elementNames) > 0){
			$groupTitle = $this->getGroupTitle($property);
			$this->form->createGroup("property_{$encodedUri}", $groupTitle, $elementNames);
		}

    }
199234
public static function register_elements() {
		foreach ( self::$_elements as $element => $locations ) {
			$class = self::get_element_class_name( $element );

			if ( method_exists( $class, 'init' ) ) {
				call_user_func( [ $class, 'init' ], $locations );
			}
		}
	}
230869
protected function initForm()
    {
        (isset($this->options['name'])) ? $name = $this->options['name'] : $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 property action in toolbar
        $actions     = tao_helpers_form_FormFactory::getCommonActions();
        $propertyElt = tao_helpers_form_FormFactory::getElement('property', 'Free');
        $propertyElt->setValue(
            "<a href='#' class='btn-info property-adder small'><span class='icon-property-add'></span> " . __('Add property') . "</a>"
        );
        $actions[] = $propertyElt;

        //property mode
        $propModeELt = tao_helpers_form_FormFactory::getElement('propMode', 'Free');
        if($this->propertyMode == 'advanced'){
            $propModeELt->setValue("<a href='#' class='btn-info property-mode small property-mode-simple'><span class='icon-property-advanced'></span> ".__('Simple Mode')."</a>");
        }
        else{
            $propModeELt->setValue("<a href='#' class='btn-info property-mode small property-mode-advanced'><span class='icon-property-advanced'></span> ".__('Advanced Mode')."</a>");
        }

        $actions[] = $propModeELt;

        //add a hidden field that states it is a class edition form.
        $classElt = tao_helpers_form_FormFactory::getElement('tao.forms.class', 'Hidden');
        $classElt->setValue('1');
        $classElt->addClass('global');
        $this->form->addElement($classElt);

        $this->form->setActions($actions, 'top');
        $this->form->setActions($actions, 'bottom');


    }
1293116
public function init() {
		// run parents to setup sanitization filters
		$data = uix()->request_vars( 'post' );
		if ( isset( $data[ 'uixNonce_' . $this->id() ] ) && wp_verify_nonce( $data[ 'uixNonce_' . $this->id() ], $this->id() ) ) {
			$this->save_data();
		} else {
			// load data normally
			$this->set_data( array( $this->slug => $this->load_data() ) );
		}
		// set the wrapper element based on static or not
		if ( ! empty( $this->struct['static'] ) ) {
			$this->element = 'div';
		}
	}
1331876
protected function InitForm()
    {
        $this->html = $this->LoadElement();
        $name = 'Html';
        $this->AddRichTextField($name, $this->html->GetHtml());
        $this->AddCssClassField();
        $this->AddCssIDField();
        $this->AddCacheLifetimeField();
        $this->AddSubmit();
    }
245395
protected function init()
    {
        $this->attributes = [];
        $this->groupAttributes = [];

        $this->attributes['id'] = $this->open->name . '-' . $this->name;

        if($this->name) {
            $this->attributes['name'] = $this->name;
        }
    }
23402
public function init()
    {
        $this->attributes['type'] = $this->type;
        echo Html::beginForm($this->action, $this->method, $this->attributes);

        return new Form;
    }
995558
public function init()
    {
        if ($this->form->enableClientScript === true && $this->form->enableClientValidation === true) {
            Html::addCssClass($this->inputOptions, ['inputValidation' => 'validate']);
        }

        if ($this->model->hasErrors()) {
            Html::addCssClass($this->inputOptions, $this->form->errorCssClass);
        }

        if ($this->showCharacterCounter === true) {
            $this->inputOptions['showCharacterCounter'] = true;
        }
    }
1027457
public function init()
    {
        $this->assets = array(
            'js' => YII_DEBUG ? 'foundation/foundation.topbar.js' : 'foundation.min.js'
        );

        Html::addCssClass($this->htmlOptions, Enum::NAV_TOPBAR);
        if ($this->fixed) {
            Html::addCssClass($this->htmlOptions, Enum::NAV_FIXED);
        }
        if ($this->sticky) {
            Html::addCssClass($this->htmlOptions, Enum::NAV_STICKY);
        }
        if ($this->containToGrid) {
            Html::addCssClass($this->htmlOptions, Enum::NAV_CONTAINED);
        }

        parent::init();
    }
863260
public function init()
    {
        $this->assets = array(
            'js' => YII_DEBUG ? 'foundation/foundation.reveal.js' : 'foundation.min.js'
        );

        Html::addCssClass($this->htmlOptions, Enum::DIALOG);
        $this->setId(ArrayHelper::removeValue($this->htmlOptions, 'id', $this->getId()));
        $this->registerClientScript();
        parent::init();

        $this->htmlOptions['id'] = $this->getId();

        echo $this->renderToggleButton() . "\n";
        echo \CHtml::openTag('div', $this->htmlOptions) . "\n";
        echo $this->renderHeader() . "\n";
    }
495807
public function initForm()
    {
        $this->form = tao_helpers_form_FormFactory::getForm('loginForm');

        $connectElt = tao_helpers_form_FormFactory::getElement('connect', 'Submit');
        $connectElt->setValue(__('Log in'));
        $connectElt->setAttributes(array('disabled' => 'disabled'));
        $connectElt->addClass('disabled');
        $this->form->setActions(array($connectElt), 'bottom');
    }
953969
public function init()
    {
        $this->setIsDisableCapable(false)
             ->setIsDisableElementsCapable(false);

        $this->setForms(
            array(
            'contact' => array(
                'type' => 'Auth/UserInfo',
                'property' => true,
            ),
            'image' => array(
                'type' => 'Applications/ContactImage',
                'property' => true,
                'use_files_array' => true,
            ),
            )
        );
    }
1231880
public function init()
    {
        if (!isset($this->options['id'])) {
            $this->options['id'] = $this->getId();
        }
        if ($this->init) {
            echo Html::beginForm($this->action, $this->method, $this->options);
        }
    }
1276117
protected function initForm()
    {
    	parent::initForm();
    	
    	$this->form->setName($this->formName);
    	
		$actions = tao_helpers_form_FormFactory::getCommonActions('top');
		$this->form->setActions($actions, 'top');
		$this->form->setActions($actions, 'bottom');
    }
1138695
protected function initElements()
    {

        
    	$chainingElt = tao_helpers_form_FormFactory::getElement('chaining', 'Radiobox');
		$chainingElt->setDescription(__('Filtering mode'));
		$chainingElt->setOptions(array('or' =>  __('Exclusive (OR)'), 'and' => __('Inclusive (AND)')));
		$chainingElt->setValue('or');
		$this->form->addElement($chainingElt);
		
		$recursiveElt = tao_helpers_form_FormFactory::getElement('recursive', 'Checkbox');
		$recursiveElt->setDescription(__('Scope'));
		$recursiveElt->setOptions(array('0' =>  __('Search sub-classes')));
		$this->form->addElement($recursiveElt);

		$searchClassUriElt = tao_helpers_form_FormFactory::getElement("clazzUri", "Hidden");
		$searchClassUriElt->setValue(tao_helpers_Uri::encode($this->clazz->getUri()));
		$this->form->addElement($searchClassUriElt);
		
		$langElt = tao_helpers_form_FormFactory::getElement('lang', 'Combobox');
		$langElt->setDescription(__('Language'));
		
		$languages = array_merge(array('-- any --'), tao_helpers_I18n::getAvailableLangsByUsage(new core_kernel_classes_Resource(tao_models_classes_LanguageService::INSTANCE_LANGUAGE_USAGE_DATA)));
		$langElt->setOptions($languages);
		$langElt->setValue(0);
		$this->form->addElement($langElt);
		
		$this->form->createGroup('params', __('<del>Options</del>'), array('chaining', 'recursive', 'lang'));
		

		$filters = array();

		$defaultProperties 	= tao_helpers_form_GenerisFormFactory::getDefaultProperties();
		$classProperties	= $this->getClassProperties();

		
		$properties = array_merge($defaultProperties, $classProperties);
		
		(isset($this->options['recursive'])) ? $recursive = $this->options['recursive'] : $recursive = false;
		if($recursive){
			foreach($this->clazz->getSubClasses(true) as $subClass){
				$properties = array_merge($subClass->getProperties(false), $properties);
			}
		}
		
		foreach($properties as $property){
	
			$element = tao_helpers_form_GenerisFormFactory::elementMap($property);
			if( ! is_null($element) && 
				! $element instanceof tao_helpers_form_elements_Authoring && 
				! $element instanceof tao_helpers_form_elements_Hiddenbox &&
				! $element instanceof tao_helpers_form_elements_Hidden ){
				
				if($element instanceof tao_helpers_form_elements_MultipleElement){
					$newElement = tao_helpers_form_FormFactory::getElement($element->getName(), 'Checkbox');
					$newElement->setDescription($element->getDescription());
					$newElement->setOptions($element->getOptions());
					$element = $newElement;
				}
				if($element instanceof tao_helpers_form_elements_Htmlarea){
					$newElement = tao_helpers_form_FormFactory::getElement($element->getName(), 'Textarea');
					$newElement->setDescription($element->getDescription());
					$element = $newElement;
				}
				
				$this->form->addElement($element);
				$filters[] = $element->getName();
			}
		}
		$this->form->createGroup('filters', __('<del>Filters</del>'), $filters);
    	
        
    }
1045629
protected function initItems()
    {
        if (is_null($this->_items)) {
            // Set the element classes
            $model = $this->getModel();
            $keys  = $model->getKeys();

            foreach ($model->getItemNames() as $item) {
                if (($item == $this->receptionCodeItem) || in_array($item, $this->editItems)) {
                    continue;
                }
                if (in_array($item, $this->exhibitItems)) {
                    $model->set($item, 'elementClass', 'Exhibitor');
                } elseif (in_array($item, $this->hiddenItems)) {
                    $model->set($item, 'elementClass', 'Hidden');
                } elseif (in_array($item, $keys)) {
                    $model->set($item, 'elementClass', 'Hidden');
                } else {
                    $model->set($item, 'elementClass', 'None');
                }
            }

            $this->_items = array_merge(
                    $this->hiddenItems,
                    $this->exhibitItems,
                    array($this->receptionCodeItem),
                    $this->editItems
                    );
        }
    }
311658
protected function InitForm()
    {
        $this->htmlWrap = $this->LoadElement();
        $name = 'Html';
        $this->AddRichTextField($name, $this->htmlWrap->GetHtml());
        $this->AddCssClassField();
        $this->AddCssIDField();
        $this->AddSubmit();
    }