Create form object

@param string|object $model model class or object
@param string $formClass form class, default use Phalcon\Forms\Form
@return Phalcon\Forms\Form
973260
public function createForm($model, $formClass = null)
    {
        if (is_string($model)) {
            return $this->createFormInternal($model, new $model, $formClass);
        } else {
            return $this->createFormInternal(get_class($model), $model, $formClass);
        }
    }
1311802
public function setModel($modelClass) {
		$reflection = new ReflectionClass($modelClass);
		
		if (! $reflection->implementsInterface('ZExt\Model\ModelInterface')) {
			throw new Exception('Class of a model must implements "ModelInterface"');
		}
		
		$this->_modelClass = $modelClass;
		
		return $this;
	}
898080
protected function _addClass(FormHelper $formHelper, $options, $class)
    {
        $bootstrap = isset($options['bootstrap']) ? (bool)$options['bootstrap'] : true;
        if ($bootstrap) {
            $options = $formHelper->addClass((array)$options, $class);
        }

        if (isset($options['bootstrap'])) {
            unset($options['bootstrap']);
        }

        return $options;
    }
796917
public function createDeleteForm($entity, $entityClass)
    {
        return $this->createIdForm($entity, 'delete_', $this->adminRouter->generate($entity, $entityClass, AdminRouter::TYPE_DELETE));
    }
716772
public function add_model($class, $instance = null, $method = 'set_form_fields')
	{
		$this->fieldset->add_model($class, $instance, $method);

		return $this;
	}
925049
public function save(Model $model)
    {
        $model->setAttribute($this->getMorphType(), $this->morphClass);

        return parent::save($model);
    }
476771
public function createValidator(string $rulesClass): FormValidatorInterface
    {
        /** @var SettingsProviderInterface $settingsProvider */
        $settingsProvider = $this->getContainer()->get(SettingsProviderInterface::class);
        $serializedData   = S::getFormSerializedRules($settingsProvider->get(S::class));

        /** @var FormatterFactoryInterface $factory */
        $factory   = $this->getContainer()->get(FormatterFactoryInterface::class);
        $formatter = $factory->createFormatter(Messages::NAMESPACE_NAME);

        $validator = new FormValidator(
            $rulesClass,
            FormRulesSerializer::class,
            $serializedData,
            new ContextStorage(FormRulesSerializer::readBlocks($serializedData), $this->getContainer()),
            $formatter
        );

        return $validator;
    }
1254008
public function create( $model, $config = [] ) {

		$modelClass = static::$modelClass;

		// Default New
		$model->status = $model->status ?? $modelClass::STATUS_NEW;

		// Create Model
		return parent::create( $model, $config );
	}
236263
public function create($model = null, array $options = [])
    {
        $options += ['process' => false, 'jsForm' => false];
        $options = $this->addClass($options, $this->_class('form'));

        $isProcess = $options['process'];

        if ($isProcess !== false) {
            $_options = [
                'url' => [
                    'plugin'     => $this->request->getParam('plugin'),
                    'controller' => $this->request->getParam('controller'),
                    'action'     => 'process'
                ]
            ];

            $options['jsForm'] = true;
            $options = Hash::merge($_options, $options);
        }

        $isJsForm = $options['jsForm'];
        if ($isJsForm) {
            $this->_isJsForm = true;
            $options = $this->addClass($options, 'jsForm');
        }

        unset($options['process'], $options['jsForm']);

        return parent::create($model, $options);
    }
56153
public function createJsModel(Form $form)
    {
        $this->currentElement = $form;

        $conf = $form->getConfig();
        // If field is disabled or has no any validations
        if (false === $conf->getOption('js_validation')) {
            return null;
        }

        $model                 = new JsFormElement;
        $model->id             = $this->getElementId($form);
        $model->name           = $form->getName();
        $model->type           = get_class($conf->getType()->getInnerType());
        $model->invalidMessage = $this->translateMessage(
            $conf->getOption('invalid_message'),
            $conf->getOption('invalid_message_parameters')
        );
        $model->transformers   = $this->normalizeViewTransformers(
            $form,
            $this->parseTransformers($conf->getViewTransformers())
        );
        $model->bubbling       = $conf->getOption('error_bubbling');
        $model->data           = $this->getValidationData($form);
        $model->children       = $this->processChildren($form);

        $prototype = $form->getConfig()->getAttribute('prototype');
        if ($prototype) {
            $model->prototype = $this->createJsModel($prototype);
        }

        // Return self id to add it as child to the parent model
        return $model;
    }
599395
public function processForm( $form, $formModel ) {

		$formSubmit = $formModel->processFormSubmit( $form );

		$this->triggerNotification( $form );

		return $formSubmit;
    }
764250
public function creating(Model $model)
    {
        $count = method_exists($model, 'getCounter') ? $model->getCounter() : ($model::count() ?? 0);

        $column = method_exists($model, 'getReferenceColumn') ? $model->getReferenceColumn() : 'reference';

        $prefix = method_exists($model, 'referencePrefix') ? $model->referencePrefix() : config('document.prefix');

        if (Schema::hasColumn($model->getTable(), $column) && is_null($model->$column)) {
            $model->$column = generate_reference($prefix, $count);
        }
    }
491803
public function form($model)
    {
        return $this->form->of('orchestra.users', function (FormGrid $form) use ($model) {
            $form->resource($this, 'orchestra/foundation::users', $model);

            $form->hidden('id');

            $form->fieldset(function (Fieldset $fieldset) {
                $fieldset->control('input:text', 'email')
                    ->label(trans('orchestra/foundation::label.users.email'));

                $fieldset->control('input:text', 'fullname')
                    ->label(trans('orchestra/foundation::label.users.fullname'));

                $fieldset->control('input:password', 'password')
                    ->label(trans('orchestra/foundation::label.users.password'));

                $fieldset->control('select', 'roles[]')
                    ->label(trans('orchestra/foundation::label.users.roles'))
                    ->attributes(['multiple' => true])
                    ->options(function () {
                        $roles = app('orchestra.role');

                        return $roles->pluck('name', 'id');
                    })
                    ->value(function ($user) {
                        // get all the user roles from objects
                        return $user->roles()->get()->pluck('id')->all();
                    });
            });
        });
    }
1206632
public function formProperty()
    {
        if ($this->formProperty === null) {
            $this->formProperty = false;

            if ($this->objType() && $this->propertyIdent()) {
                $propertyIdent = $this->propertyIdent();

                $model = $this->modelFactory()->create($this->objType());
                if ($model->hasProperty($propertyIdent)) {
                    $this->formProperty = $model->property($propertyIdent);
                }
            }
        }

        return $this->formProperty;
    }
553974
private Object makeModelObject(String formName) {
		Object object = null;
		Class modelClass = null;
		try {
			modelClass = (Class) modelFactory.getModelClasses(formName);
			if (modelClass == null) {
				throw new Exception(" not found the model in config xml, formName=" + formName);
			}
			object = modelClass.newInstance();
			// inject
			modelProxyInjection.injectProperties(object);
		} catch (Exception e) {
			Debug.logError("[JdonFramework]--> call Model: " + modelClass + " error:" + e, module);
		}
		return object;
	}
190598
protected function setFormClass($formClass){

        if (is_string($formClass)){
            $formClass = explode(" " , $formClass);
        }

        $this->formClass = $formClass;
    }
180693
protected function createTableModel(Model $model = null) {
		$phalconModel = new PhalconModel($this->getTableModelDi());
		$phalconModel->setDatagate($this);
		
		if ($model !== null) {
			$phalconModel->assign($model->getData());
		}
		
		return $phalconModel;
	}