PHPackages                             freesoftwarefactory/smartform - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. freesoftwarefactory/smartform

ActiveProject[Utility &amp; Helpers](/categories/utility)

freesoftwarefactory/smartform
=============================

Build forms automatically. Advanced controls. Yii2

1.0.0004(8y ago)049MITJavaScriptPHP &gt;=5.3.2

Since Sep 24Pushed 8y ago1 watchersCompare

[ Source](https://github.com/freesoftwarefactory/smartform)[ Packagist](https://packagist.org/packages/freesoftwarefactory/smartform)[ RSS](/packages/freesoftwarefactory-smartform/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Setup
=====

[](#setup)

1. Install this class to make it visible

    ```
     cd /your/app/components;
     ln -s ../vendor/freesoftwarefactory/smartform/SmartformWidget.php .

    ```
2. Setup a config file by installing it in your 'params' section,

    ```
     // copy the template from ./template/smartform.php to:
     'field-groups'=>require(__DIR__.'/my-smart-form-settings.php'),

    ```

Usage
=====

[](#usage)

```
[php]

	use yii\widgets\ActiveForm;

    $form = ActiveForm::begin();
	echo \app\components\SmartformWidget::widget([
		'config_entry'=>'field-groups',
		'form_id'=>'form-1',
		'active_form'=>$form,
		'model'=>$model,
	]);
	ActiveForm::end();

```

Callback Examples
=================

[](#callback-examples)

Sometimes a callback is required to get values from it.

Callback Example: Read select options from database.
----------------------------------------------------

[](#callback-example-read-select-options-from-database)

```
[php]

	...html...

```

How to Upload a File
====================

[](#how-to-upload-a-file)

1. in your config file define a field named "product\_image" in this way:

```
"product_image"=>"upload_one_picture",

```

2. in the widget definition, add a inline callback. this is used to tell the widget where to put the $\_POST and $\_FILES.

```
		echo \app\components\SmartformWidget::widget([
			'config_entry'=>'field-groups',
			'form_id'=>'some-form-id',
			'active_form'=>$form,
			'model'=>$model,
			'callback' => function($_call,$_model,$_fieldname){

				if('get_file_upload_url'==$_call){
					return \yii\helpers\Url::toRoute(['ajax-upload-product-image']);
				}

				if('instance_files' == $_call){
					$list = [];
					if('product_image'==$_fieldname) $list[] = [
						'id'=>1, 'file_name'=>'', 'file_path'=>'',
						'preview_url'=>'/media/landingpage/product/thumb/'.$_model->id,
						'delete_url'=>'',
					];
					return $list;
				}
			}
		]);

```

3. the controller which will receive the $\_POST and $\_FILES should declare a action and some exceptions to CSRF:

```
	// methods required in the controller:

	public function beforeAction($action) {
		if($action->id == 'ajax-upload-product-image')
			$this->enableCsrfValidation = false;
		return parent::beforeAction($action);
	}

	public function actionAjaxUploadProductImage(){
		if(!Yii::$app->request->isAjax) die('invalid ajax request');
		\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

		$model_id=filter_input(INPUT_POST,"model_id",FILTER_SANITIZE_STRING);

		// this will help you to get more information:
		Yii::info("UPLOAD_INFO\n", print_r(["POST"=>$_POST,"FILES"=>$_FILES],true));

		$model = $this->findModel($model_id);
		$tmp_file = $_FILES['Landingpage']['tmp_name']['product_image'];
		$binary_data = file_get_contents($tmp_file);

		return [];
	}

```

4. only for your information, the LOG injected into the action will tell you something like the following, so use this information in order to get your file:

```
$_POST = [
    'file_id' => '0'
    'model_id' => '1'
    'field_name' => 'product_image'
]
$_FILES = [
    'Landingpage' => [
        'name' => [
            'product_image' => 'foto_1_verde.jpg'
        ]
        'type' => [
            'product_image' => 'image/jpeg'
        ]
        'tmp_name' => [
            'product_image' => '/tmp/phppQhABh'
        ]
        'error' => [
            'product_image' => 0
        ]
        'size' => [
            'product_image' => 2597
        ]
    ]
]

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~207 days

Total

3

Last Release

3099d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/84c1ee8cb7752defef9778c9ffa49ff57421a276b262f8a64477496465758949?d=identicon)[christiansalazar](/maintainers/christiansalazar)

---

Top Contributors

[![christiansalazar](https://avatars.githubusercontent.com/u/1652867?v=4)](https://github.com/christiansalazar "christiansalazar (5 commits)")

### Embed Badge

![Health badge](/badges/freesoftwarefactory-smartform/health.svg)

```
[![Health](https://phpackages.com/badges/freesoftwarefactory-smartform/health.svg)](https://phpackages.com/packages/freesoftwarefactory-smartform)
```

###  Alternatives

[aaronfrancis/flaky

A Laravel package to elegantly handle flaky operations.

41524.8k](/packages/aaronfrancis-flaky)[cedaro/woocommerce-coupon-links

A WordPress plugin to automatically apply a WooCommerce coupon code to the cart with a URL.

13770.4k](/packages/cedaro-woocommerce-coupon-links)[execut/yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

46170.2k](/packages/execut-yii2-widget-bootstraptreeview)[mouf/classname-mapper

Provides a way to find in which PHP files a class will be looked upon.

112.3M5](/packages/mouf-classname-mapper)[tarfin-labs/zbar-php

zbar-php is a php package that provides an interface to the zbar bar-code reading library.

2593.2k](/packages/tarfin-labs-zbar-php)[fkr/simplepie-bundle

Integrates SimplePie into Symfony

11137.5k](/packages/fkr-simplepie-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
