当前位置: 首页>>代码示例>>PHP>>正文


PHP FormHelper::create方法代码示例

本文整理汇总了PHP中FormHelper::create方法的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper::create方法的具体用法?PHP FormHelper::create怎么用?PHP FormHelper::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormHelper的用法示例。


在下文中一共展示了FormHelper::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

	public function create($model = null, $options = array()) {
		
		if (!empty($options['inputDefaults'])){
			extract($options['inputDefaults']);
			$class = (!empty($class))? 'form-control '.$class:'form-control';
			$before = (!empty($before))? '<div class="form-group">'.$before : '<div class="form-group">';
			$between = (!empty($between))? '<div class="col-sm-10"> '.$between:'<div class="col-sm-10">';
			$after = (!empty($after))? '</div></div> '.$after:'</div></div>';
			if ((!empty($label)) and is_array($label)) {
				$label['class'] = (!empty($label['class']))? 'control-label col-sm-2 '.$label: 'control-label col-sm-2';
			} else if (!empty($label)) {
				$label['text'] = $label;
				$label['class'] = 'control-label col-sm-2';
			}
		} else {
			$class = 'form-control';
			$before = '<div class="form-group">';
			$between = '<div class="col-sm-10">';
			$after = '</div></div>';
			$label['class'] = 'control-label col-sm-2 ';
		}

		$options['class'] = (empty($options['class']))?'form-horizontal':'form-horizontal '.$options['class'];
		$options['role'] = (empty($options['role']))?'form':'form '.$options['role'];

		$options['inputDefaults']['class'] = $class;
		$options['inputDefaults']['before'] = $before;
		$options['inputDefaults']['between'] = $between;
		$options['inputDefaults']['after'] = $after;
		$options['inputDefaults']['label'] = $label;
		$options['inputDefaults']['div']=false;

		return parent::create($model, $options);
	}
开发者ID:patrickacioli,项目名称:exames,代码行数:34,代码来源:FormTbHelper.php

示例2: create

 /**
  * フォーム開始タグを作成する
  * 
  * @param type $model
  * @param type $options
  * @return string
  */
 public function create($model = null, $options = array())
 {
     if (!is_null($model) && !$this->_model instanceof $model) {
         $this->_model = ClassRegistry::init($model);
     }
     return parent::create($model, $options);
 }
开发者ID:Shiro-Nwal,项目名称:sin-kaisha-khine,代码行数:14,代码来源:ExtFormHelper.php

示例3: create

 /**
  * Overwrite FormHelper::create()
  *
  * Added: Automatically specifies inputDefaults depending on form class
  *
  * Returns an HTML FORM element.
  *
  * ### Options:
  *
  * - `type` Form method defaults to POST
  * - `action`  The controller action the form submits to, (optional).
  * - `url`  The URL the form submits to. Can be a string or a URL array. If you use 'url'
  *    you should leave 'action' undefined.
  * - `default`  Allows for the creation of Ajax forms. Set this to false to prevent the default event handler.
  *   Will create an onsubmit attribute if it doesn't not exist. If it does, default action suppression
  *   will be appended.
  * - `onsubmit` Used in conjunction with 'default' to create ajax forms.
  * - `inputDefaults` set the default $options for FormHelper::input(). Any options that would
  *   be set when using FormHelper::input() can be set here. Options set with `inputDefaults`
  *   can be overridden when calling input()
  * - `encoding` Set the accept-charset encoding for the form. Defaults to `Configure::read('App.encoding')`
  *
  * @param mixed $model The model name for which the form is being defined. Should
  *   include the plugin name for plugin models. e.g. `ContactManager.Contact`.
  *   If an array is passed and $options argument is empty, the array will be used as options.
  *   If `false` no model is used.
  * @param array $options An array of html attributes and options.
  * @return string An formatted opening FORM tag.
  * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-create
  */
 public function create($model = null, $options = array())
 {
     if ($bootstrapVersion = Configure::read('BoostCake.bootstrap_version')) {
         if (is_array($model) && empty($options)) {
             $options = $model;
             $model = null;
         }
         $bootstrapClasses = array_keys(Configure::read("BoostCake.inputDefaults.{$bootstrapVersion}"));
         if (!isset($options['class'])) {
             $formClasses = array('default');
         } else {
             $formClasses = explode(' ', $options['class']);
         }
         $formClasses = array_reverse($formClasses);
         $formClasses[] = 'default';
         foreach ($formClasses as $formClass) {
             if (in_array($formClass, $bootstrapClasses)) {
                 $class = $formClass;
                 break;
             }
         }
         if ($inputDefaults = Configure::read("BoostCake.inputDefaults.{$bootstrapVersion}.{$class}")) {
             $options = Hash::merge(array('inputDefaults' => $inputDefaults), $options);
         }
     }
     $html = parent::create($model, $options);
     return $html;
 }
开发者ID:hiryu85,项目名称:cakephp-boost-cake,代码行数:58,代码来源:BoostCakeFormHelper.php

示例4: create

 public function create($model = null, $options = array())
 {
     if (empty($options['class'])) {
         $options['class'] = 'well';
     }
     return parent::create($model, $options);
 }
开发者ID:nnanna217,项目名称:Mastering-CakePHP,代码行数:7,代码来源:BootstrapFormHelper.php

示例5: create

 /**
  * Adds the class `form-horizontal` as its required by bootstrap
  *
  */
 public function create($model = null, $options = array())
 {
     if (is_array($model) && empty($options)) {
         $options = $model;
         $model = null;
     }
     $defaults = array('class' => 'form-horizontal');
     $options = Set::merge($defaults, $options);
     return parent::create($model, $options);
 }
开发者ID:wangshipeng,项目名称:license,代码行数:14,代码来源:BootstrapFormHelper.php

示例6: create

 public function create($model = null, $options = array())
 {
     $defaultOptions = array('inputDefaults' => array('div' => array('class' => 'form-group'), 'label' => array('class' => 'col-lg-2 control-label'), 'between' => '<div class="col-lg-10">', 'seperator' => '</div>', 'after' => '</div>', 'class' => 'form-control'), 'class' => 'form-horizontal', 'role' => 'form');
     if (!empty($options['inputDefaults'])) {
         $options = array_merge($defaultOptions['inputDefaults'], $options['inputDefaults']);
     } else {
         $options = array_merge($defaultOptions, $options);
     }
     return parent::create($model, $options);
 }
开发者ID:ristorantino,项目名称:ristorantino,代码行数:10,代码来源:BootstrapFormHelper.php

示例7: create

 public function create($model = null, $options = array())
 {
     $defaultOptions = array('class' => 'form-horizontal', 'inputDefaults' => array('format' => array('before', 'label', 'between', 'input', 'error', 'after'), 'div' => 'control-group', 'label' => array('class' => 'control-label'), 'between' => '<div class="controls">', 'after' => '</div>', 'error' => array('attributes' => array('wrap' => 'span', 'class' => 'help-inline'))));
     if (!empty($options['inputDefaults'])) {
         $options = array_merge($defaultOptions['inputDefaults'], $options['inputDefaults']);
     } else {
         $options = array_merge($defaultOptions, $options);
     }
     return parent::create($model, $options);
 }
开发者ID:quangnga,项目名称:servers,代码行数:10,代码来源:MyFormHelper.php

示例8: create

 /**
  * Makes sure language prefix is always set
  * @param null $model
  * @param array $options
  * @return string
  */
 public function create($model = null, $options = array())
 {
     if (!isset($options['url']['language']) && isset($this->params['language']) && !is_string($options['url'])) {
         if (!isset($options['url'])) {
             $options['url'] = array();
         }
         $options['url']['language'] = $this->params['language'];
     }
     return parent::create($model, $options);
 }
开发者ID:mathg,项目名称:skinsound,代码行数:16,代码来源:MyFormHelper.php

示例9: create

 public function create($model = null, $options = array())
 {
     $form = parent::create($model, $options);
     if (isset($this->params['named']['backTo'])) {
         $form .= $this->hidden('params.backTo', array('value' => $this->params['named']['backTo']));
     }
     if (isset($this->data['params']['backTo'])) {
         $form .= $this->hidden('params.backTo', array('value' => $this->data['params']['backTo']));
     }
     return $form;
 }
开发者ID:ricog,项目名称:smart_redirect,代码行数:11,代码来源:extended_form.php

示例10: create

 public function create($model = null, $options = array())
 {
     //$mainLabelOptions = array('class' => 'col-sm-2 control-label');
     $defaultOptions = array('inputDefaults' => array('div' => array('class' => 'form-group'), 'format' => array('before', 'label', 'between', 'input', 'error', 'after'), 'between' => '<span class="col-sm-6">', 'error' => array('attributes' => array('wrap' => 'span', 'class' => 'text-danger margin-left-5 number'))));
     if (!empty($options['inputDefaults'])) {
         $options = array_merge($defaultOptions['inputDefaults'], $options['inputDefaults']);
     } else {
         $options = array_merge($defaultOptions, $options);
     }
     return parent::create($model, $options);
 }
开发者ID:shawon922,项目名称:osas,代码行数:11,代码来源:MyFormHelper.php

示例11: create

 /**
  * adds the default class 'form-horizontal to the <form>
  *
  */
 public function create($model = null, $options = array())
 {
     if (isset($this->request['language']) && !empty($options['url'])) {
         if (is_array($options['url'])) {
             $options['url']['language'] = Configure::read('Config.langCode');
         } else {
             $options['url'] = '/' . $this->request['language'] . $options['url'];
         }
     }
     $class = array('class' => 'form-horizontal');
     $options = array_merge($class, $options);
     return parent::create($model, $options);
 }
开发者ID:cepedag14,项目名称:phkondo,代码行数:17,代码来源:BootstrapFormHelper.php

示例12: create

    /**
     * Add a form key after two seconds to help secure the form.
     */
    public function create($model = null, $options = array())
    {
        if ($options['secure'] === true) {
            // this piece is copied from the parent function, because we need the id earlier
            if (!isset($options['id'])) {
                $domId = isset($options['action']) ? $options['action'] : $this->request['action'];
                $options['id'] = $this->domId($domId . 'Form');
            }
            // hash the form action to write into settings, as a form that must be checked
            $settingValue = 'c' . Security::hash($this->url($this->_getAction($options)), 'md5', Configure::read('Security.salt'));
            // this is how we know which forms have to be checked on the catch side
            if (defined('__APP_SECURE_FORMS')) {
                // read settings
                $values = unserialize(__APP_SECURE_FORMS);
                $saveNewForm = false;
                if (!in_array($settingValue, $values['form'])) {
                    // add to settings if it isn't in there already
                    array_push($values['form'], $settingValue);
                    $value = '';
                    foreach ($values['form'] as $formId) {
                        $value .= 'form[] = ' . $formId . PHP_EOL;
                    }
                    $saveNewForm = true;
                }
            } else {
                // add setting value
                $value = 'form[] = ' . $settingValue;
                $saveNewForm = true;
            }
            if (!empty($saveNewForm)) {
                $Setting = ClassRegistry::init('Setting');
                $data['Setting']['type'] = 'App';
                $data['Setting']['name'] = 'SECURE_FORMS';
                $data['Setting']['value'] = $value;
                $Setting->add($data);
            }
            // this code is extremely slow, it can cause pages to take two minutes to load
            $context = stream_context_create(array('http' => array('header' => 'Connection: close\\r\\n')));
            $json = json_decode(file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/forms/forms/secure.json', false, $context));
            echo '<script type="text/javascript">
			        jQuery(document).ready(function() {
			          var timeOut = window.setTimeout(function() { jQuery("#' . $options['id'] . '").prepend("<input type=\\"hidden\\" name=\\"data[FormKey][id]\\" value=\\"' . $json->key . '\\" />"); }, 10000);
			        });
			      </script>';
        }
        if ($options['action'] === null && $options['url'] === null) {
            // zuha over writes the the action if it isn't specified to preserve the prefix and query string (cake < 2.4 did for us)
            $options['url'] = $_SERVER['REQUEST_URI'];
        }
        return parent::create($model, $options);
    }
开发者ID:ajayphp,项目名称:Zuha,代码行数:54,代码来源:ZuhaFormHelper.php

示例13: create

 function create($model = null, $options = array())
 {
     $options = array_merge(array('fieldset' => true), $options);
     if ($options['fieldset'] !== false) {
         $append = $this->fieldset($options['fieldset']);
     }
     if (isset($options['class'])) {
         $options['class'] .= ' uniForm';
     } else {
         $options['class'] = 'uniForm';
     }
     unset($options['fieldset']);
     return parent::create($model, $options) . $append;
 }
开发者ID:kouak,项目名称:ircube,代码行数:14,代码来源:uni_form.php

示例14: create

 /**
  * Create
  *
  * @param $model string
  * @param $options array
  * @return string
  */
 public function create($model = null, $options = array())
 {
     if (empty($options['class'])) {
         $options['class'] = 'well';
     }
     $modelKey = $this->model();
     $Model = ClassRegistry::init($modelKey);
     if (!empty($Model->displayFieldTypes[$modelKey])) {
         if (in_array('image', $Model->displayFieldTypes[$modelKey]) || in_array('file', $Model->displayFieldTypes[$modelKey])) {
             $type_val = array('type' => 'file');
             $options = array_merge($type_val, $options);
         }
     }
     return parent::create($model, $options);
 }
开发者ID:hughc,项目名称:Admin,代码行数:22,代码来源:BootstrapFormHelper.php

示例15: create

 public function create($model, $options = array())
 {
     //$this->_inputDefaults = $this->_myInputDefaults;
     $defaults = $this->_defaults;
     $defaults['inputDefaults'] = $this->_myInputDefaults;
     if (is_array($options['inputDefaults'])) {
         foreach ($options['inputDefaults'] as $k => $v) {
             $defaults['inputDefaults'][$k] = $v;
         }
         unset($options['inputDefaults']);
     }
     $options = Set::merge($defaults, $options);
     $this->_model = $model;
     return parent::create($model, $options);
 }
开发者ID:jet77,项目名称:DiabeteSavior,代码行数:15,代码来源:BootstrapFormHelper.php


注:本文中的FormHelper::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。