FormController ------------------------
777960
public function actionSubmit( $slug, $type = null ) {

		if( !isset( $type ) ) {

			$type = CoreGlobal::TYPE_FORM;
		}

		$model 		= $this->formService->getBySlugType( $slug, $type );
		$template	= $model->template;
		$formFields	= $model->getFieldsMap();
 		$form		= new GenericForm( [ 'fields' => $formFields, 'ajax' => true ] );

		if( $model->captcha ) {

			$form->setScenario( 'captcha' );
		}

		if( $form->load( Yii::$app->request->post(), 'GenericForm' ) && $form->validate() ) {

			// Save Model
			if( $this->formService->processForm( $model, $form ) ) {

				// Trigger User Mail
				if( $model->userMail ) {

					Yii::$app->formsMailer->sendUserMail( $model, $form );
				}

				// Trigger Admin Mail
				if( $model->adminMail ) {

					Yii::$app->formsMailer->sendAdminMail( $model, $form );
				}

				$data = [];

				// Set success message
				if( isset( $model->success ) ) {

					$data[ 'message' ] = $model->success;
				}

				// Trigger Ajax Success
				return AjaxUtil::generateSuccess( $model->success, $data );
			}
		}

		// Generate Errors
		$errors = AjaxUtil::generateErrorMessage( $form );

		// Trigger Ajax Failure
    	return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
    }
1054025
protected function createComponentEditForm(): Form
	{
		$form = $this->formFactory->create();
		$form->addProtection();

		$form->addText('username', 'cms.user.username')
			->setDefaultValue($this->currentUser->username)
			->setRequired();
		$form->addText('firstName', 'cms.user.firstName')
			->setDefaultValue($this->currentUser->firstName);
		$form->addText('surname', 'cms.user.surname')
			->setDefaultValue($this->currentUser->surname);
		$form->addText('email', 'cms.user.email')
			->setDefaultValue($this->currentUser->email)
			->setRequired()
			->addRule(Form::EMAIL);
		$form->addPhone('phone', 'cms.user.phone')
			->setDefaultValue($this->currentUser->phone);

		$language = $form->addSelectUntranslated('language', 'cms.user.language', $this->localeService->allowed, 'form.none');
		if (!empty($this->currentUser->language)) {
			$locale = $this->localeService->get($this->currentUser->language);
			if ($locale) {
				$language->setDefaultValue($locale->id);
			}
		}

		$roles = $form->addMultiSelectUntranslated('roles', 'cms.permissions.roles', $this->orm->aclRoles->fetchPairs($this->user->isAllowed('dockbar.settings.permissions.superadmin', 'view')))
			->setRequired();
		try {
			$roles->setDefaultValue($this->currentUser->roles->getRawValue());
		} catch (InvalidArgumentException $ex) {

		}

		$form->addSubmit('save', 'form.save');
		$form->addLink('back', 'form.back', $this->getBacklink());

		$form->onSuccess[] = [$this, 'editFormSucceeded'];

		return $form;
	}
538430
public function init() {

        parent::init();

		// Views
		$this->setViewPath( '@cmsgears/module-core/admin/views/config' );

		// Permission
		$this->crudPermission = FormsGlobal::PERM_FORM_ADMIN;

		// Config
		$this->type		= CoreGlobal::TYPE_SYSTEM;
		$this->apixBase = 'core/form';
		$this->submits	= false;

		// Services
		$this->modelService = Yii::$app->factory->get( 'cmsgears\core\common\services\interfaces\resources\IFormService' );

		// Sidebar
		$this->sidebar = [ 'parent' => 'sidebar-form', 'child' => 'config' ];

		// Return Url
		$this->returnUrl = Url::previous( 'configs' );
		$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/forms/config/all' ], true );

		// Breadcrumbs
		$this->breadcrumbs = [
			'base' => [
				[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ]
			],
			'all' => [ [ 'label' => 'Forms' ] ],
			'create' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
			'update' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
			'delete' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ],
			'fields' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Fields' ] ]
		];
	}
435191
public function form()
    {
        return $this->scaffoldForm()
                    ->without(['slug'])
                    ->update('parent_id', function (FormElement $element) {
                        $control = new Select('parent_id');
                        $control->setOptions(['' => '--Select--'] + pages()->lists());

                        return $element->setInput($control);
                    });
    }
1253545
function modelControllerExtension (ModelControllerInterface $modelController)
  {
    $request = $modelController->getRequest ();
    $files   = $request->getUploadedFiles ();

    $uploads = [];

    $this->processDropzoneFiles($request, $modelController);

    // Check if extension is applicable to the current request.
    foreach ($files as $fieldName => $file)
      if (str_endsWith ($fieldName, self::FILE_FIELD_SUFFIX)) {
        // Note: slashes are converted to dots, which delimit path segments to nested fields. See the Field component.
        $fieldName           = str_replace ('/', '.', str_segmentsStripLast ($fieldName, self::FILE_FIELD_SUFFIX));
        $uploads[$fieldName] = $file;
      }

      if ($uploads)
        $modelController->onSave (-1, function () use ($uploads, $modelController) {
          /** @var UploadedFileInterface $file */
          foreach ($uploads as $fieldName => $file) {
            list ($targetModel, $prop) = $modelController->getTarget ($fieldName);
            $err = $file->getError ();
            if ($err == UPLOAD_ERR_OK)
              static::newUpload ($targetModel, $prop, $file);
						else if ($err == UPLOAD_ERR_INI_SIZE)
             throw new FlashMessageException ("Error Imagem demasiado grande", FlashType::ERROR, "Error uploading file");
            else if ($err == UPLOAD_ERR_NO_FILE)
              static::noUpload ($targetModel, $prop);
            else throw new FlashMessageException ("Error $err", FlashType::ERROR, "Error uploading file");
          }
        });
  }
259434
protected function createComponentEditForm(): Form
	{
		$form = $this->formFactory->create();

		$form->addText('name', 'default.name')
			->setRequired();

		if ($this->editConst) {
			$form->addText('const', 'webManager.web.content.const')
				->setRequired();

			$form->addSelectUntranslated('locale', 'webManager.web.pages.locale')
				->setItems($this->localeService->allowed);
		}

		$form->addText('title', 'webManager.web.content.contentTitle')
			->addRule(Form::MAX_LENGTH, null, 150)
			->setRequired(false);

		$form->addTextArea('keywords', 'webManager.web.content.keywords');

		$form->addImageUpload('image', 'webManager.web.content.photo', 'webManager.web.content.photoDelete')
			->setNamespace('content')
			->setPreview('300x100');

		$form->addColor('background', 'webManager.web.content.background');

		$form->addTextArea('description', 'webManager.web.content.description');

		$form->addTextEditor('content', 'webManager.web.content.content');

		$form->addSubmit('save', 'form.save');

		$form->addLink('back', 'form.back', $this->getBacklink());

		$form->onSuccess[] = [$this, 'editFormSucceeded'];

		return $form;
	}
255526
protected function createComponentConfigurationForm(): Form
	{
		$form = $this->formFactory->create();
		$form->setAjaxRequest();

		$form->addGroup('cms.settings.basic');
		$form->addImageUpload('cmsLogo', 'cms.settings.logo', 'cms.settings.deleteLogo')
			->setNamespace('cms')
			->setPreview('300x100');
		$form->addCheckbox('sendNewUserPassword', 'cms.settings.sendNewUserPassword');
		$form->addCheckbox('sendChangePassword', 'cms.settings.sendChangePassword');
		$form->addCheckbox('dockbarAdvanced', 'cms.settings.dockbarAdvanced');
		$form->addSelectUntranslated('defaultLocale', 'cms.settings.defaultLocale', $this->localeService->fetch())
			->setDefaultValue($this->localeService->defaultLocaleId);
		$form->addMultiSelectUntranslated('allowedLocales', 'cms.settings.allowedLocales', $this->localeService->fetch())
			->setDefaultValue($this->localeService->allowedLocaleIds)
			->setRequired();

		$form->addGroup('cms.settings.development');
		if (!$this->tracy->isEnabled()) {
			$form->addLink('debugOn', 'cms.settings.debugOn')
				->link($this->link('debug!', true))
				->setAjaxRequest()
				->addClass('btn-success')
				->setAttribute('data-ajax-off', 'history');
		} else {
			$form->addLink('debugOff', 'cms.settings.debugOff')
				->link($this->link('debug!', false))
				->setAjaxRequest()
				->addClass('btn-danger')
				->setAttribute('data-ajax-off', 'history');
		}
		$form->addCheckbox('mailPanel', 'cms.settings.mailPanel')
			->setDefaultValue($this->configurator->mailPanel);

		$form->getRenderer()->primaryButton = $form->addSubmit('save', 'form.save');

		$form->onSuccess[] = [$this, 'configurationFormSucseeded'];

		return $form;
	}
929549
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);


        $this->form->setActions(\tao_helpers_form_FormFactory::getCommonActions(), 'bottom');
    }
113813
private function beforeForm() {
    // Add Bootstrap CSS if is enabled
    $form_class = "";
    if ( $this -> isUsingBootstrap() ) {
      echo $this -> constants -> getBootstrapCSS();
      if( $this -> bootstrap_form_orientation == "horizontal" ){
        $form_class = "form-horizontal";
      }else if( $this -> bootstrap_form_orientation = "inline" ){
        $form_class = "form-inline";
      }
    }

    // Render form header
    echo "<form method='" . $this -> form_method . "' action='" . $this -> form_action . "' class='" . $form_class . "'>";
  }
306016
protected function buildForm()
    {
        $this->formBuilder
            ->add(
                'host',
                'text',
                array(
                    'constraints' => array(
                        new NotBlank(),
                    ),
                )
            )
            ->add(
                'user',
                'text',
                array(
                    'constraints' => array(
                        new NotBlank(),
                    ),
                )
            )
            ->add(
                'password',
                'text',
                array(
                    'constraints' => array(
                        new NotBlank(),
                    ),
                )
            )
            ->add(
                'port',
                'text',
                array(
                    'constraints' => array(
                        new NotBlank(),
                        new GreaterThan(
                            array(
                                'value' => 0,
                            )
                        ),
                    ),
                )
            )
            ->add(
                'locale',
                'hidden',
                array(
                    'constraints' => array(
                        new NotBlank(),
                    ),
                )
            );
    }
135762
public function render(Nette\Forms\Form $form, $mode = null)
    {
        $form->getElementPrototype()->setClass('form-inline');

        foreach ($form->getControls() as $control) {
            if ($control instanceof Controls\Button) {
                $usedPrimary = true;
            } elseif ($control instanceof Controls\TextBase ||
                $control instanceof Controls\SelectBox ||
                $control instanceof Controls\MultiSelectBox) {
                $control->getControlPrototype()->addClass('form-control');
            } elseif ($control instanceof Controls\Checkbox ||
                $control instanceof Controls\CheckboxList ||
                $control instanceof Controls\RadioList) {
                $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
            }
        }

        return parent::render($form, $mode);
    }
105459
public function bindToController()
    {
        if ($this->controller->widget === null) {
            $this->controller->widget = new stdClass;
        }

        $this->controller->widget->{$this->alias} = $this;
    }
707304
protected function _prepareForm()
    {
        $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
        $model = $this->_coreRegistry->registry('row_data');
        $form = $this->_formFactory->create(
            ['data' => [
                'id' => 'edit_form',
                'enctype' => 'multipart/form-data',
                'action' => $this->getData('action'),
                'method' => 'post'
            ]
            ]
        );

        $form->setHtmlIdPrefix('worldnettps_securecard_');
        if ($model->getEntityId()) {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __('Edit Row Data'), 'class' => 'fieldset-wide']
            );
            $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']);
        } else {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __('Add Row Data'), 'class' => 'fieldset-wide']
            );
        }

        $fieldset->addField(
            'title',
            'text',
            [
                'name' => 'title',
                'label' => __('Title'),
                'id' => 'title',
                'title' => __('Title'),
                'class' => 'required-entry',
                'required' => true,
            ]
        );

        $wysiwygConfig = $this->_wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]);

        $fieldset->addField(
            'content',
            'editor',
            [
                'name' => 'content',
                'label' => __('Content'),
                'style' => 'height:36em;',
                'required' => true,
                'config' => $wysiwygConfig
            ]
        );

        $fieldset->addField(
            'publish_date',
            'date',
            [
                'name' => 'publish_date',
                'label' => __('Publish Date'),
                'date_format' => $dateFormat,
                'time_format' => 'HH:mm:ss TT',
                'class' => 'validate-date validate-date-range date-range-custom_theme-from',
                'class' => 'required-entry',
                'style' => 'width:200px',
            ]
        );
        $fieldset->addField(
            'is_active',
            'select',
            [
                'name' => 'is_active',
                'label' => __('Status'),
                'id' => 'is_active',
                'title' => __('Status'),
                'values' => $this->_options->getOptionArray(),
                'class' => 'status',
                'required' => true,
            ]
        );
        $form->setValues($model->getData());
        $form->setUseContainer(true);
        $this->setForm($form);

        return parent::_prepareForm();
    }
726599
protected function loadFormData()
    {
        if (! $this->formData) {
            parent::loadFormData();

            $model     = $this->getModel();
            $roles     = $model->get('ggp_role', 'multiOptions');
            $userRoles = $this->currentUser->getAllowedRoles();

            // \MUtil_Echo::track($userRoles, $roles);
            // Make sure we get the roles as they are labeled
            foreach ($roles as $role => $label) {
                if (! isset($userRoles[$role])) {
                    unset($roles[$role]);
                }
            }

            if ($this->formData['ggp_role'] && (! isset($roles[$this->formData['ggp_role']]))) {
                if ($this->createData) {
                    $this->formData['ggp_role'] = reset($roles);
                } else {
                    $this->addMessage($this->_('You do not have sufficient privilege to edit this group.'));
                    $this->afterSaveRouteUrl = array($this->request->getActionKey() => 'show');
                    $this->resetRoute        = false;
                    return;
                }
            }
            $model->set('ggp_role', 'multiOptions', $roles);

            $this->menu->getParameterSource()->offsetSet('ggp_role', $this->formData['ggp_role']);
        }
    }
51746
public function run()
    {
        $dataType = DataType::where('slug', 'posts')->firstOrFail();

        if (!$dataType->exists) {
            return false;
        }

        FormDesigner::firstOrCreate([
            'data_type_id' => $dataType->id,
            'options'      => json_encode([
                [
                    'class'  => 'col-md-8',
                    'panels' => [
                        [
                            'class'  => 'panel',
                            'title'  => '<i class="admin-character"></i> Post Title The title for your post',
                            'fields' => [
                                'title',
                            ],
                        ],
                        [
                            'class'  => 'panel',
                            'title'  => 'Post Content',
                            'fields' => [
                                'body',
                            ],
                        ],
                        [
                            'class'  => 'panel',
                            'title'  => 'Excerpt <small>Small description of this post</small>',
                            'fields' => [
                                'excerpt',
                            ],
                        ],
                    ],
                ],
                [
                    'class'  => 'col-md-4',
                    'panels' => [
                        [
                            'class'  => 'panel panel-warning',
                            'title'  => 'Post Details',
                            'fields' => [
                                'slug',
                                'status',
                                'category_id',
                                'featured',
                            ],
                        ],
                        [
                            'class'  => 'panel panel-primary',
                            'title'  => 'Post Image',
                            'fields' => [
                                'image',
                            ],
                        ],
                        [
                            'class'  => 'panel panel-info',
                            'title'  => 'admin.post.seo_content',
                            'fields' => [
                                'meta_keywords',
                                'meta_description',
                                'seo_title',
                            ],
                        ],
                    ],
                ],
            ]),
        ]);
    }
699608
public function setup() {

		$this->struct['modal'] = $this->get_base();
		$this->config();
		$this->struct['modal']['config']['view'] = $this->struct['modal']['config']['template'];
		unset( $this->struct['modal']['config']['template'] );
		add_action( 'uix_control_item_submit_' . $this->slug, $this->struct['modal']['config']['callback'], 100 );
		parent::setup();
		$this->set_submit();
	}
1135791
protected function getFormClassNameFromControllerAction()
    {
        return $this->controllerService->getFormClassNameFromControllerAction(
            $this->getControllerName(),
            $this->getControllerActionName(),
            $this->getFormObjectName()
        );
    }