定制 emildev/simpleform2b 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

emildev/simpleform2b

最新稳定版本:v2.0

Composer 安装命令:

composer require emildev/simpleform2b

包简介

Create simple forms directly in your controller. Supports all input-types, textarea and submit

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage

SimpleForm2B - README

A simple form-creator for Anax MVC built with php. Supports all input-types, textarea and submit.

Installation

Download package from packagist using

composer require emildev/simpleform2b

from your console. When this is done, you can enter your vendor folder and navigate to emildev/simpleform2b. Inside you will find two folders, src and webroot. Inside the src is the main module, leave it there. If you head over to webroot, you will find a folder named simpleform2b. copy that folder and put it in your views directory.

Usage - creating the SimpleForm2B object

Now that the package is properly installed, you can start to use the module. To include the module in your controller, simply create an object with the following reference.

\emildev\SimpleForm2B\SimpleForm2B();

An example where I create an $auth object that contains the SimpleForm2B module would hence look like this:

$auth = new \emildev\SimpleForm2B\SimpleForm2B();

Usage - using the the SimpleForm2B object

SimpleForm2B contains 5 different methods.

  • setForm()
  • setInput()
  • setTextArea()
  • setSubmit()
  • saveForm()

How to use them is explained below

setForm()

setForm() opens the form and contains 3 parameters:

  1. Method
  2. Action
  3. Class

These three parameters are not optional and should always be set before using other methods. An example where I create a new form with the method of post, the action of url:register/check and the class of registerForm should hence look like this:

$auth->setForm('post', $this->url->create('register/check'), 'registerForm');

setInput()

setInput() creates an input type and contains 6 parameters:

  1. type
  2. name
  3. value - optional
  4. id - optional
  5. label - optional
  6. placeholder - optional

If you choose not to use a parameter, define NULL in it's place. You can create how many input-fields you want. They will show up in the order you write them in the controller. An example where I create an input-field with the type of text, name of username, no-value, id of username, label of Insert Username and no-placeholder would look like this:

$auth->setInput('text', 'username', NULL, 'username', 'Insert Username', NULL);

setTextArea()

setTextArea() creates a textarea for your form. It consists of 5 parameters:

  1. name
  2. value - optional
  3. id - optional
  4. label - optional
  5. placeholder - optional

If you choose not to use a parameter, define NULL in it's place. You can only create one textarea for each form, and it will always end up under the input-fields. An example where I create a textarea with the name of textarea, no-value, no-id, label of Write info and no-placeholder would look like this:

$auth->setTextArea('textarea', NULL, NULL, 'Write info', NULL);

setSubmit()

setSubmit() creates a submit-button at the bottom of your form. It has 2 non-optional parameters:

  1. name
  2. value

This method is quite self-explanatory but if you want to create a submit button which contains the name of submitThis and a value of Send, this is how you write it in your controller:

$auth->setSubmit('submitThis', 'Send');

saveForm()

saveForm() should always be included after all other methods are set. It contains 0 parameters and offers you a way to save the form into a variable which you can pass along to the view. An example of saving the form into the variable $myNewForm would look like this:

$myNewForm = $auth->saveForm();

When passing along the variable to the view, it should always be named 'form'. An example on how to implement this into Anax-Mvc would be:

$this->views->add('simpleform2b/simpleform2b', [
				'form' => $myNewForm
				]);

Finally

With SimpleForm2B, you can easily create forms in lightning speed. The above information should be everything you need to know. If you still end up with problems, you are free to contact me at emil.wallgren@hotmail.se

Have Fun!

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-10-16