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


PHP Formo::add方法代码示例

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


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

示例1: load

 public static function load(Jelly_Model $model, Formo $form, array $fields = NULL)
 {
     $skip_fields = array();
     if ($fields and in_array('*', $fields)) {
         $skip_fields = $fields;
         $fields = NULL;
     }
     foreach ($model->meta()->fields() as $column => $field) {
         if (in_array($column, $skip_fields)) {
             continue;
         }
         if ($fields and !in_array($column, $fields)) {
             continue;
         }
         $options = (array) $field + array('value' => $model->get($column));
         // Fetch the validation key names from the config file
         $validation_keys = Kohana::config('formo_jelly')->validation_keys;
         // Add specific rules
         if ($options['unique'] === TRUE) {
             // If the field is set to unique, add the rule to check for other records
             $options[$validation_keys['rules']][':model::unique'] = array($column);
         }
         // Look for validation rules as defined by the config file
         foreach ($validation_keys as $key => $value) {
             // If they are using the assumed names, do nothing
             if ($key === $value) {
                 continue;
             }
             // Only grab the proper validation settings from jelly field definition
             $options[$key] = !empty($options[$value]) ? $options[$value] : array();
             // No need to carry duplicates for a rule
             unset($options[$value]);
         }
         // NOTE: This shouldn't really happen until pre_render
         /*
         			$options = array('value' => $model->get($column));
         			
         			$add_options = array('driver', 'rules', 'filters', 'triggers', 'post_filters');
         			
         			foreach ($add_options as $option)
         			{
         				if ( ! empty($field->$option))
         				{
         					$options[$option] = $field->$option;
         				}
         			}
         */
         $form->add($column, $options);
     }
 }
开发者ID:vitch,项目名称:kohana-formo,代码行数:50,代码来源:core.php

示例2: _process_has_many

 protected static function _process_has_many($alias, Kohana_ORM $model, stdClass $std, Formo $form)
 {
     if (empty($std->has_many)) {
         // No need to process non-has-many fields here
         return NULL;
     }
     foreach (Arr::get($std->has_many, 'definitions', array()) as $key => $values) {
         if (Arr::get($values, 'formo') === true) {
             $rs_all = ORM::factory($values['model'])->find_all();
             $foreign_model = ORM::factory($values['model']);
             $rs_in = $foreign_model->where($values['foreign_key'], '=', $model->pk())->find_all();
             $opts = static::select_list($rs_all, $foreign_model->primary_key(), static::_get_field_name($foreign_model));
             $val = static::select_list($rs_in, $foreign_model->primary_key(), $foreign_model->primary_key());
             $form->add($key, 'checkboxes', $val, array('opts' => $opts));
         } else {
             $form->add($key, 'checkboxes', null, array('render' => false));
         }
     }
 }
开发者ID:bmidget,项目名称:kohana-formo,代码行数:19,代码来源:Kohana.php


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