GithubHelp home page GithubHelp logo

yii2-widgets-button's Introduction

Yii2-Widgets-Button

This extension Extends and enhances the Yii ActiveForm widget. Encapsulates the three form layout: default, horizontal, inline. To help developers to quickly create the form. At the same time, we and extends and enhances the Yii ActiveField widget. Details please refer to the following instructions and Yii2-Toolkit API Documentation.

NOTE: This extension dependent on the reparsoft/Yii2-Toolkit-Base extension. Check This extension the bundled composer.json requirements and dependencies. At the same time, This extension has been encapsulated in reparsoft/Yii2-Widgets extension. Unified call namespace repkit\widgets. If the user choose custom installation other extensions, at use of time, namespace Please refer API Documentation of origin namespace description.

Installation

The preferred way to install this extension is through composer. Remember to refer to the bundled composer.json for this extension's requirements and dependencies.

Install

Either run

$ php composer.phar require reparsoft/yii2-widgets-activeform "*"

or add

"reparsoft/yii2-widgets-activeform": "*"

to the require section of your composer.json file.

##Usage

ActiveForm

use \repkit\form\ActiveForm;

$form = ActiveForm::begin([
  //...settings options

  'layout' => ActiveForm::LAYOUT_HORIZONTAL,
  'fieldConfig' = [
      
  ]
]);

  //contents....


$form::end();

Settings Options

layout: [string] set form layout.

  • defaultValue: default
  • Optional constants:
    • default: [self::LAYOUT_DEFAULT].
    • horizontal: (self::LAYOUT_HORIZONTAL).
    • inline: (self::LAYOUT_INLINE).

horizontalLayout: [array|empty] horizontal layout configuration.

  • options: [label, offset, wrapper, error, hint]

Example:

horizontalLayout = [
  'label' => 'col-sm-5',
  'offset' => 'col-sm-offset-8',
  'wrapper' => 'col-sm-3',
  'error' => '',
  'hint' => 'col-sm-8',
]

fieldConfig [array|empty] ActiveField default global configuration. configuration detail Please refer to the ActiveField README.md or API Documentation.

ActiveFiled

use \repkit\form\ActiveForm;

$form = ActiveForm::begin([
  //...settings options
]);

  echo $form->field($model, AttributeName, [
          //ActiveField settings options

          'enableLabel' => true,
          'enableError' => false
       ]);


  echo $form->field($model, AttributeName, [
          //ActiveField settings options
       ])->textInput([
          //ActiveField settings options
       ]);

$form::end();

Settings Options

inline: [boolean] whether to render [[checkboxList()]] and [[radioList()]] inline.

  • default: false

enableLabel: [boolean|empty] Whether enable label.

enableError: [boolean|empty] Whether enable error.

wrapperOptions: [array|empty] input wrapper options.

inputTemplate: [string|empty] input template.

addon: [array|empty] addon plugin.

  • options: [options, before|after]

    • before|after options: [asbtn, content].
    • asbtn: [boolean|empty] Whether the button.
  • Example:

      addon => [
        'options' => [...],
        'before' => [
          'content' => '...'
        ],
        'after' => [
          'asbtn' => true,
          'content' => [....]
        ]
      ]
    

addonOptions: [array|empty] addon options.

checkboxTemplate [string|empty] the template for checkboxes in default layout.

horizontalCheckboxTemplate: [string|empty] the template for checkboxes in horizontal layout.

radioTemplate: [string|empty] the template for radios in default layout.

horizontalRadioTemplate: [string|empty] the template for radio buttons in horizontal layout.

inlineCheckboxListTemplate: [string|empty] the template for inline checkboxLists.

inlineRadioListTemplate: [string|empty] the template for inline radioLists.

Example

use \repkit\form\ActiveForm;

$form = ActiveForm::begin([
  'layout' => ActiveForm::LAYOUT_HORIZONTAL,
  'horizontalLayout' => [
      'label' => 'col-sm-1',
      'offset' => 'col-sm-offset-6',
      'wrapper' => 'col-sm-6',
      'error' => '',
      'hint' => 'col-sm-5',
  ],
  'fieldConfig' => [
     'enableLabel' => false,
     'enableError' => true
  ],

]);

echo $form->field($model, 'username',[
  'enableError' => false,
  'enableLabel' => false,
  
  'addon' => [
    'options' => [
       'data-toggle' => 'addon'
    ],

     'before' => [
         'content' => '@'
     ],

     'after' => [
         'asbtn' => true,
         'content' => 
             '<button type="button" class="btn btn-default" 
                 tabindex="-1">下拉菜单
              </button>
              <button type="button" class="btn btn-default 
                 dropdown-toggle" data-toggle="dropdown" tabindex="-1">
                 <span class="caret"></span>
                 <span class="sr-only">切换下拉菜单</span>
              </button>
              <ul class="dropdown-menu pull-right">
                 <li><a href="#">功能</a></li>
                 <li><a href="#">另一个功能</a></li>
                 <li><a href="#">其他</a></li>
                 <li class="divider"></li>
                 <li><a href="#">分离的链接</a></li>
              </ul>'
      ]
   ]
])->hint('用户姓名由于[a-zA-Z]组成');

$form::end();

Yii2-Toolkit API Documentation

License

This extension is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.

yii2-widgets-button's People

Contributors

joyzx avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.