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


PHP Fieldset::instance方法代码示例

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


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

示例1: set_fields

 /**
  * Set a Model's properties as fields on a Fieldset, which will be created with the Model's
  * classname if none is provided.
  *
  * @param   string
  * @param   Fieldset|null
  * @return  Fieldset
  */
 public static function set_fields($obj, $fieldset = null)
 {
     static $_generated = array();
     $class = is_object($obj) ? get_class($obj) : $obj;
     if (is_null($fieldset)) {
         $fieldset = \Fieldset::instance($class);
         if (!$fieldset) {
             $fieldset = \Fieldset::factory($class);
         }
     }
     !array_key_exists($class, $_generated) and $_generated[$class] = array();
     if (in_array($fieldset, $_generated[$class], true)) {
         return $fieldset;
     }
     $_generated[$class][] = $fieldset;
     $fieldset->validation()->add_callable($obj);
     $properties = is_object($obj) ? $obj->properties() : $class::properties();
     foreach ($properties as $p => $settings) {
         $field = $fieldset->add($p, !empty($settings['label']) ? $settings['label'] : $p);
         if (empty($settings['validation'])) {
             continue;
         } else {
             foreach ($settings['validation'] as $rule => $args) {
                 if (is_int($rule) and is_string($args)) {
                     $args = array($args);
                 } else {
                     array_unshift($args, $rule);
                 }
                 call_user_func_array(array($field, 'add_rule'), $args);
             }
         }
     }
     return $fieldset;
 }
开发者ID:469306621,项目名称:Languages,代码行数:42,代码来源:validation.php

示例2: set_fields

 /**
  * Set a Model's properties as fields on a Fieldset, which will be created with the Model's
  * classname if none is provided.
  *
  * @param   string
  * @param   Fieldset|null
  * @return  Fieldset
  */
 public static function set_fields($class, $fieldset = null)
 {
     $properties = $class::properties();
     if (is_null($fieldset)) {
         $fieldset = \Fieldset::instance($class);
         if (!$fieldset) {
             $fieldset = \Fieldset::factory($class);
         }
     }
     foreach ($properties as $p => $settings) {
         $field = $fieldset->add($p, !empty($settings['label']) ? $settings['label'] : $p);
         if (empty($settings['validation'])) {
             continue;
         } else {
             foreach ($settings['validation'] as $rule => $args) {
                 if (is_int($rule) and is_string($args)) {
                     $args = array($args);
                 } else {
                     array_unshift($args, $rule);
                 }
                 call_user_func_array(array($field, 'add_rule'), $args);
             }
         }
     }
     return $fieldset;
 }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:34,代码来源:validation.php

示例3: get_form

 private function get_form($type = 0)
 {
     $form = Fieldset::instance();
     if (count($form->field()) > 0) {
         return $form;
     }
     switch ($type) {
         case SettingType::PASSWORD:
             $form->add("mail_address_new", "新しいメールアドレス");
             $form->add("mail_address_new_confirm", "新しいメールアドレス(確認)");
             $form->add("password", "現在のパスワード")->add_rule("required");
             $form->add("password_new", "新しいパスワード")->add_rule("required")->add_rule("min_length", 4)->add_rule("max_length", 30)->add_rule("valid_string", array("alpha", "numeric"));
             $form->add("password_new_confirm", "新しいパスワード(確認)")->add_rule("required")->add_rule("match_field", "password_new");
             break;
         case SettingType::MAILADDRESS:
             $form->add("mail_address_new", "新しいメールアドレス")->add_rule("required")->add_rule("valid_email");
             $form->add("mail_address_new_confirm", "新しいメールアドレス(確認)");
             $form->add("password", "現在のパスワード");
             $form->add("password_new", "新しいパスワード");
             $form->add("password_new_confirm", "新しいパスワード(確認)");
             break;
         default:
             break;
     }
     return $form;
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:26,代码来源:setting.php

示例4: get_form

 private function get_form()
 {
     $form = Fieldset::instance();
     if (count($form->field()) > 0) {
         return $form;
     }
     $form->add('email', 'メールアドレス')->add_rule('required')->add_rule('max_length', 30)->add_rule('valid_email');
     $form->add('password', 'パスワード')->add_rule('required')->add_rule('max_length', 30);
     $form->add('remember', 'パスワードを保存する')->add_rule('match_value', '1');
     return $form;
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:11,代码来源:auth.php

示例5: action_password

 /**
  * Mmeber setting password
  * 
  * @access  public
  * @return  Response
  */
 public function action_password()
 {
     if (!($form = Fieldset::instance('setting_password'))) {
         $form = $this->form_setting_password();
     }
     if (Input::method() === 'POST') {
         $form->repopulate();
     }
     $this->set_title_and_breadcrumbs(term('site.password', 'form.update'), array('member/setting/' => term('site.setting', 'form.update')), $this->u);
     $this->template->content = View::forge('_parts/setting/password');
     $this->template->content->set_safe('html_form', $form->build('member/setting/change_password'));
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:18,代码来源:setting.php

示例6: action_index

 /**
  * Mmeber leave
  * 
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     if (!($form = Fieldset::instance('leave'))) {
         $form = $this->form_leave();
     }
     if (Input::method() === 'POST') {
         $form->repopulate();
     }
     $this->set_title_and_breadcrumbs(term('site.left'), array('member/setting' => term('site.setting', 'form.update')), $this->u);
     $this->template->content = View::forge('member/leave/index');
     $this->template->content->set_safe('html_form', $form->build('member/leave/confirm'));
     // form の action に入る
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:19,代码来源:leave.php

示例7: action_resend_password

 /**
  * Resend password
  * 
  * @access  public
  * @return  Response
  */
 public function action_resend_password()
 {
     if (!($form = Fieldset::instance('resend_password'))) {
         $form = $this->form_resend_password();
     }
     if (Input::method() === 'POST') {
         $form->repopulate();
     }
     $this->set_title_and_breadcrumbs(term('site.password') . 'の再設定');
     $this->template->content = View::forge('member/recover/resend_password');
     $this->template->content->set_safe('html_form', $form->build('member/recover/send_reset_password_mail'));
     // form の action に入る
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:19,代码来源:recover.php

示例8: get_form

 private function get_form()
 {
     $form = Fieldset::instance();
     if (count($form->field()) > 0) {
         return $form;
     }
     $form->add('ope');
     $form->add('id');
     $form->add('name', 'お名前')->add_rule('required')->add_rule('max_length', 50);
     $form->add('email', 'メールアドレス')->add_rule('required');
     $form->add('status', 'ステータス')->add_rule('required');
     return $form;
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:13,代码来源:user.php

示例9: get_form

 private function get_form()
 {
     $form = Fieldset::instance();
     if (count($form->field()) > 0) {
         return $form;
     }
     $form->add("contact_type", "お問い合わせ項目")->add_rule("required")->add_rule("match_pattern", "/" . implode("|", array_keys($this->contactType)) . "/");
     $form->add("name", "お名前")->add_rule("required")->add_rule("max_length", 50);
     $form->add("name_kana", "お名前(フリガナ)")->add_rule("required")->add_rule("max_length", 50)->add_rule("valid_katakana");
     $form->add("tel", "電話番号")->add_rule("required")->add_rule("valid_tel");
     $form->add("mail_address", "メールアドレス")->add_rule("required")->add_rule("valid_email");
     $form->add("mail_address_confirm", "メールアドレス(確認)")->add_rule("required")->add_rule("match_field", "mail_address");
     $form->add("contact_detail", "お問い合わせ内容")->add_rule("required")->add_rule("max_length", 1000);
     $form->add("agree", "同意")->add_rule("match_value", 1);
     return $form;
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:16,代码来源:contact.php

示例10: set_fields

 /**
  * Set a Model's properties as fields on a Fieldset, which will be created with the Model's
  * classname if none is provided.
  *
  * @param   string
  * @param   Fieldset|null
  * @return  Fieldset
  */
 public static function set_fields($obj, $fieldset = null)
 {
     static $_generated = array();
     $class = is_object($obj) ? get_class($obj) : $obj;
     if (is_null($fieldset)) {
         $fieldset = \Fieldset::instance($class);
         if (!$fieldset) {
             $fieldset = \Fieldset::forge($class);
         }
     }
     !array_key_exists($class, $_generated) and $_generated[$class] = array();
     if (in_array($fieldset, $_generated[$class], true)) {
         return $fieldset;
     }
     $_generated[$class][] = $fieldset;
     $primary_keys = is_object($obj) ? $obj->primary_key() : $class::primary_key();
     $properties = is_object($obj) ? $obj->properties() : $class::properties();
     foreach ($properties as $p => $settings) {
         if (\Arr::get($settings, 'skip', in_array($p, $primary_keys))) {
             continue;
         }
         if (isset($settings['form']['options'])) {
             foreach ($settings['form']['options'] as $key => $value) {
                 is_array($value) or $settings['form']['options'][$key] = \Lang::get($value, array(), false) ?: $value;
             }
         }
         // field attributes can be passed in form key
         $attributes = isset($settings['form']) ? $settings['form'] : array();
         // label is either set in property setting, as part of form attributes or defaults to fieldname
         $label = isset($settings['label']) ? $settings['label'] : (isset($attributes['label']) ? $attributes['label'] : $p);
         $label = \Lang::get($label, array(), false) ?: $label;
         // create the field and add validation rules
         $field = $fieldset->add($p, $label, $attributes);
         if (!empty($settings['validation'])) {
             foreach ($settings['validation'] as $rule => $args) {
                 if (is_int($rule) and is_string($args)) {
                     $args = array($args);
                 } else {
                     array_unshift($args, $rule);
                 }
                 call_user_func_array(array($field, 'add_rule'), $args);
             }
         }
     }
     return $fieldset;
 }
开发者ID:highestgoodlikewater,项目名称:webspider-1,代码行数:54,代码来源:validation.php

示例11: set_fields

 /**
  * Set a Model's properties as fields on a Fieldset, which will be created with the Model's
  * classname if none is provided.
  *
  * @param   string
  * @param   Fieldset|null
  * @return  Fieldset
  */
 public static function set_fields($obj, $fieldset = null)
 {
     static $_generated = array();
     $class = is_object($obj) ? get_class($obj) : $obj;
     if (is_null($fieldset)) {
         $fieldset = \Fieldset::instance($class);
         if (!$fieldset) {
             $fieldset = \Fieldset::forge($class);
         }
     }
     !array_key_exists($class, $_generated) and $_generated[$class] = array();
     if (in_array($fieldset, $_generated[$class], true)) {
         return $fieldset;
     }
     $_generated[$class][] = $fieldset;
     $primary_keys = is_object($obj) ? $obj->primary_key() : $class::primary_key();
     $properties = is_object($obj) ? $obj->properties() : $class::properties();
     foreach ($properties as $p => $settings) {
         if (in_array($p, $primary_keys)) {
             continue;
         }
         if (isset($settings['form']['options'])) {
             foreach ($settings['form']['options'] as $key => $value) {
                 $settings['form']['options'][$key] = \Lang::line($value) ?: $value;
             }
         }
         $label = isset($settings['label']) ? $settings['label'] : $p;
         $attributes = isset($settings['form']) ? $settings['form'] : array();
         $field = $fieldset->add($p, $label, $attributes);
         if (!empty($settings['validation'])) {
             foreach ($settings['validation'] as $rule => $args) {
                 if (is_int($rule) and is_string($args)) {
                     $args = array($args);
                 } else {
                     array_unshift($args, $rule);
                 }
                 call_user_func_array(array($field, 'add_rule'), $args);
             }
         }
     }
     return $fieldset;
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:50,代码来源:validation.php

示例12: action_email

 /**
  * Admin setting email
  * 
  * @access  public
  * @return  Response
  */
 public function action_email()
 {
     if (!($form = \Fieldset::instance('setting_email'))) {
         $form = $this->form_setting_email();
     }
     if (\Input::method() === 'POST') {
         $form->repopulate();
     }
     $this->set_title_and_breadcrumbs(term('site.email', 'form.update'), array('admin/setting' => term('site.setting', 'form.update')));
     $this->template->content = \View::forge('_parts/setting/email');
     $this->template->content->set_safe('html_form', $form->build('admin/setting/change_email'));
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:18,代码来源:setting.php

示例13: instance

 public static function instance($name = null)
 {
     $fieldset = \Fieldset::instance($name);
     return $fieldset === false ? false : $fieldset->validation();
 }
开发者ID:cloudetm,项目名称:development,代码行数:5,代码来源:validation.php

示例14: set_fields

 /**
  * Set a Model's properties as fields on a Fieldset, which will be created with the Model's
  * classname if none is provided.
  *
  * @param   string
  * @param   \Fieldset|null
  * @return  \Fieldset
  */
 public static function set_fields($obj, $fieldset = null)
 {
     static $_generated = array();
     static $_tabular_rows = array();
     $class = is_object($obj) ? get_class($obj) : $obj;
     if (is_null($fieldset)) {
         $fieldset = \Fieldset::instance($class);
         if (!$fieldset) {
             $fieldset = \Fieldset::forge($class);
         }
     }
     // is our parent fieldset a tabular form set?
     $tabular_form = is_object($fieldset->parent()) ? $fieldset->parent()->get_tabular_form() : false;
     // don't cache tabular form fieldsets
     if (!$tabular_form) {
         !array_key_exists($class, $_generated) and $_generated[$class] = array();
         if (in_array($fieldset, $_generated[$class], true)) {
             return $fieldset;
         }
         $_generated[$class][] = $fieldset;
     }
     $primary_keys = is_object($obj) ? $obj->primary_key() : $class::primary_key();
     $primary_key = count($primary_keys) === 1 ? reset($primary_keys) : false;
     $properties = is_object($obj) ? $obj->properties() : $class::properties();
     if ($tabular_form and $primary_key and !is_object($obj)) {
         isset($_tabular_rows[$class]) or $_tabular_rows[$class] = 0;
     }
     foreach ($properties as $p => $settings) {
         if (\Arr::get($settings, 'skip', in_array($p, $primary_keys))) {
             continue;
         }
         if (isset($settings['form']['options'])) {
             foreach ($settings['form']['options'] as $key => $value) {
                 is_array($value) or $settings['form']['options'][$key] = \Lang::get($value, array(), false) ?: $value;
             }
         }
         // field attributes can be passed in form key
         $attributes = isset($settings['form']) ? $settings['form'] : array();
         // label is either set in property setting, as part of form attributes or defaults to fieldname
         $label = isset($settings['label']) ? $settings['label'] : (isset($attributes['label']) ? $attributes['label'] : $p);
         $label = \Lang::get($label, array(), false) ?: $label;
         // change the fieldname and label for tabular form fieldset children
         if ($tabular_form and $primary_key) {
             if (is_object($obj)) {
                 $p = $tabular_form . '[' . $obj->{$primary_key} . '][' . $p . ']';
             } else {
                 $p = $tabular_form . '_new[' . $_tabular_rows[$class] . '][' . $p . ']';
             }
             $label = '';
         }
         // create the field and add validation rules
         $field = $fieldset->add($p, $label, $attributes);
         if (!empty($settings['validation'])) {
             foreach ($settings['validation'] as $rule => $args) {
                 if (is_int($rule) and is_string($args)) {
                     $args = array($args);
                 } else {
                     array_unshift($args, $rule);
                 }
                 call_fuel_func_array(array($field, 'add_rule'), $args);
             }
         }
     }
     // increase the row counter for tabular row fieldsets
     if ($tabular_form and $primary_key and !is_object($obj)) {
         $_tabular_rows[$class]++;
     }
     return $fieldset;
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:77,代码来源:validation.php

示例15: action_confirm_signup

 /**
  * Execute confirm signup
  * 
  * @access  public
  * @return  Response
  */
 public function action_confirm_signup()
 {
     Util_security::check_method('POST');
     Util_security::check_csrf();
     if (!($form = Fieldset::instance('confirm_signup'))) {
         $form = $this->get_form_signup_confirm();
     }
     $val = $form->validation();
     $val->fieldset()->field('email')->delete_rule('unique');
     $redirect_uri = conf('login_uri.site');
     $success_message = '仮登録が完了しました。受信したメール内に記載された URL より本登録を完了してください。';
     $error_message = '';
     $is_transaction_rollback = false;
     try {
         if (!$val->run()) {
             throw new \FuelException($val->show_errors());
         }
         $post = $val->validated();
         if (Model_MemberAuth::get4email($post['email'])) {
             if (conf('member.register.email.hideUniqueCheck')) {
                 Session::set_flash('message', $success_message);
                 Response::redirect($redirect_uri);
             }
             throw new FuelException('その' . term('site.email') . 'は登録できません。');
         }
         DB::start_transaction();
         $token = Model_MemberPre::save_with_token($post['email'], $post['password']);
         DB::commit_transaction();
         $mail = new Site_Mail('memberSignup');
         $mail->send($post['email'], array('register_url' => sprintf('%s?token=%s', Uri::create('member/register'), $token)));
         Session::set_flash('message', $success_message);
         Response::redirect($redirect_uri);
     } catch (EmailValidationFailedException $e) {
         Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' validation error');
         $error_message = 'メール送信エラー';
     } catch (EmailSendingFailedException $e) {
         Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' sending error');
         $error_message = 'メール送信エラー';
     } catch (\Database_Exception $e) {
         $is_transaction_rollback = true;
         $error_message = \Site_Controller::get_error_message($e, true);
     } catch (FuelException $e) {
         $is_transaction_rollback = true;
         $error_message = $e->getMessage();
     }
     if ($is_transaction_rollback && DB::in_transaction()) {
         DB::rollback_transaction();
     }
     Session::set_flash('error', $error_message);
     $this->action_signup();
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:57,代码来源:register.php


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