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


PHP Formo::factory方法代码示例

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


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

示例1: add

 public function add($client = NULL)
 {
     $client_id = $this->input->post('client') ? $this->input->post('client') : $client;
     if ($client_id == '' and $client_id != '-') {
         url::redirect('clients/new?client=' . urlencode($this->input->post('client_new')));
     }
     $invoices = ORM::factory('invoice');
     $clients = $this->cache->get('client') ? $this->cache->get('client') : ORM::factory('client')->find_all_as_array();
     // $client_list = array();
     foreach ($clients as $client) {
         $client_list[$client['id']] = $client['company'];
     }
     $data = array('hour', 'day', 'service', 'product');
     $form = Formo::factory('invoice_add')->set('class', 'simple-form')->add('invoice_id', array('class' => 'size', 'label' => 'Invoice ID'))->add('po_number', array('class' => 'size', 'label' => 'P.O. Number', 'required' => FALSE))->add_select('client', $client_list, array('class' => 'size', 'value' => $client_id))->add_textarea('notes', array('class' => 'size', 'required' => FALSE))->add('qty', array('class' => 'qty'))->add_select('type', $data)->add_textarea('description')->add('unit_price', array('class' => 'qty'))->add('submit', 'Submit');
     if ($form->validate()) {
         // echo Kohana::debug($form); die;
         $invoice = ORM::factory('invoice');
         $invoice->invoice_no = $form->invoice_id->value;
         $invoice->po_number = $form->po_number->value;
         $invoice->client_id = $form->client->value;
         $invoice->notes = $form->notes->value;
         $invoice->save();
         $item = ORM::factory('item');
         $item->qty = $form->qty->value;
         $item->description = $form->description->value;
         $item->unit_price = $form->unit_price->value;
         $item->type = $form->type->value;
         $item->invoice_id = $invoice->id;
         $item->save() and $this->cache->delete_tag('clients');
         url::redirect('invoices');
     }
     $this->template->content = new View('invoices/add', $form->get(TRUE));
     $this->template->content->client_name = $client_list[$client_id];
     $this->template->content->item_view = new View('invoices/items', $form->get(TRUE));
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:35,代码来源:invoices.php

示例2: article

 public function article($uri)
 {
     $this->template->content = View::factory('blog/view')->bind('post', $post)->bind('comments', $comments)->bind('form', $form);
     $post = ORM::factory('blog_post', (string) $uri);
     // Show 404 if we don't find posts
     if (!$post->loaded) {
         Event::run('system.404');
     }
     $comments = $post->blog_comments;
     $this->head->title->prepend($post->title);
     if (!($post->comment_status === 'open' and config::get('blog.comment_status') === 'open')) {
         return;
     }
     $form = Formo::factory()->plugin('csrf')->add('text', 'author', array('label' => __('Name')))->add('text', 'email', array('label' => __('Email')))->add('text', 'url', array('label' => __('Homepage')))->add('textarea', 'content', array('label' => __('Comment')))->add('submit', 'submit', array('label' => __('Submit')))->pre_filter('all', 'trim')->pre_filter('author', 'security::xss_clean')->pre_filter('content', 'security::xss_clean')->pre_filter('url', 'security::xss_clean')->pre_filter('url', 'format::url')->add_rule('author', 'required', __('You must provide your name'))->add_rule('author', 'length[2,40]', __('Your Name is too long'))->add_rule('email', 'valid::email', __('Email address is not valid'))->add_rule('content', 'required', __('You must enter a comment'));
     if (config::get('blog.enable_captcha') === 'yes') {
         $form->add('captcha', 'security', array('label' => __('Security code')));
         $form->security->error_msg = __('Invalid security code');
     }
     if ($form->validate()) {
         $comment = ORM::factory('blog_comment');
         $comment->author = $form->author->value;
         $comment->email = $form->email->value;
         $comment->content = $form->content->value;
         $comment->url = $form->url->value;
         $comment->ip = $this->input->ip_address();
         $comment->agent = Kohana::$user_agent;
         $comment->date = date("Y-m-d H:i:s", time());
         $post->add_comment($comment);
         Event::run('blog.comment_added', $comment);
         Cache::instance()->delete('s7n_blog_feed');
         Cache::instance()->delete('s7n_blog_feed_comments');
         url::redirect($post->url());
     }
     $form = View::factory('blog/form_comment', $form->get(TRUE));
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:35,代码来源:blog.php

示例3: index

 public function index()
 {
     $this->head->title->append(__('Settings'));
     $this->template->title = __('Settings');
     $form = Formo::factory()->plugin('csrf')->add('text', 'site_title', array('label' => __('Site title'), 'value' => config::get('s7n.site_title')))->add_select('theme', theme::available(), array('label' => __('Theme'), 'value' => config::get('s7n.theme')))->add('submit', 'submit', array('label' => __('Save')));
     if ($form->validate()) {
         config::set('s7n.site_title', $form->site_title->value);
         config::set('s7n.theme', $form->theme->value);
         message::info(__('Settings edited successfully'), 'admin/settings');
     }
     $this->template->content = View::factory('settings/settings', $form->get(TRUE));
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:12,代码来源:settings.php

示例4: test_attr

 /**
  * @dataProvider provider_attr
  */
 public function test_attr(array $construct, $attr, $val, array $checks)
 {
     $expected = TRUE;
     $result = TRUE;
     $field = Formo::factory($construct);
     if (is_array($attr)) {
         $field->attr($attr);
     } else {
         $field->attr($attr, $val);
     }
     foreach ($checks as $key => $value) {
         if ($field->attr($key) !== $value) {
             $result = FALSE;
         }
     }
     $this->assertSame($expected, $result);
 }
开发者ID:bmidget,项目名称:kohana-formo,代码行数:20,代码来源:FormoTest.php

示例5: edit

 public function edit($id)
 {
     $client = ORM::factory('client', (int) $id);
     $form = Formo::factory('client_edit')->set('class', 'smart-form')->add('company', array('class' => 'size', 'value' => $client->company))->add('address', array('class' => 'size', 'value' => $client->address))->add('address1', array('class' => 'size', 'value' => $client->address1, 'required' => FALSE))->add('city', array('class' => 'size', 'value' => $client->city))->add('postcode', array('class' => 'size', 'value' => $client->postcode))->add('phone', array('class' => 'size', 'value' => $client->phone))->add('fax', array('class' => 'size', 'value' => $client->fax, 'required' => FALSE))->add('url', array('label' => 'Website', 'class' => 'size', 'value' => $client->url, 'required' => FALSE))->add_rule('url', 'valid::url')->add('submit', 'Submit');
     if ($form->validate()) {
         $client->company = $form->company->value;
         $client->address = $form->address->value;
         $client->address1 = $form->address1->value;
         $client->city = $form->city->value;
         $client->postcode = $form->postcode->value;
         $client->phone = $form->phone->value;
         $client->fax = $form->fax->value;
         $client->url = $form->url->value;
         $client->save() and $this->cache->delete_tag('clients') and url::redirect('clients');
     }
     $this->template->content = new View('clients/add');
     $this->template->content->form = $form;
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:18,代码来源:clients.php

示例6: database_setup

 public function database_setup()
 {
     $form = Formo::factory('database_setup')->set('class', 'smart-form')->add('host', array('class' => 'size'))->add('username', array('class' => 'size'))->add('password', array('class' => 'size', 'required' => FALSE))->type('password')->add('database', array('class' => 'size'))->add('prefix', array('class' => 'size', 'value' => 'bc_'))->add('checkbox', 'drop', array('label' => 'Drop Tables', 'required' => FALSE))->add('checkbox', 'data', array('label' => 'Insert Data', 'required' => FALSE))->add('submit', 'submit', array('value' => __('Install'), 'class' => 'button'));
     if ($form->validate()) {
         try {
             setup::check_db($form->username->value, $form->password->value, $form->host->value, $form->database->value, $form->prefix->value);
             $data = array('username' => $form->username->value, 'password' => $form->password->value, 'host' => $form->host->value, 'database' => $form->database->value, 'prefix' => $form->prefix->value, 'data' => $form->data->checked);
             Session::instance()->set('database_data', $data);
             $redirect = $form->drop->checked ? 'install/step_drop_tables' : 'install/step_create_structure';
             url::redirect($redirect);
         } catch (Exception $e) {
             $error = $e->getMessage();
             Session::instance()->delete('conn_status');
             switch ($error) {
                 case 'access':
                     $conn_error = __('Wrong username or password.');
                     break;
                 case 'unknown_host':
                     $conn_error = __('Could not find the host.');
                     break;
                 case 'connect_to_host':
                     $conn_error = __('Could not connect to host.');
                     break;
                 case 'create':
                     $conn_error = __('Could not create the database.');
                     break;
                 case 'select':
                     $conn_error = __('Could not select the database.');
                     break;
                 case 'prefix':
                     $conn_error = __('The Table Prefix you chose is already in use.');
                     break;
                 default:
                     $conn_error = $error;
             }
         }
     }
     $this->template->page_title = __('Database Setup');
     $data = $form->get(TRUE);
     $this->template->content = new View('install/database_setup', $data);
     $this->template->content->success = __('%bc will work correctly with your environment', array('%bc' => Kohana::config('bc.bc')));
     $this->template->content->error = isset($conn_error) ? $conn_error : '';
     $this->template->content->passed = Session::instance()->get('conn_status');
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:44,代码来源:install.php

示例7: edit

 public function edit($id)
 {
     $this->head->title->append(__('New User'));
     $this->template->title .= __('New User');
     $user = ORM::factory('user', (int) $id);
     if (!$user->loaded) {
         Event::run('system.404');
     }
     $form = Formo::factory()->plugin('csrf')->add('text', 'username', array('label' => __('Username'), 'value' => $user->username))->add('text', 'email', array('label' => __('Email'), 'value' => $user->email))->add('password', 'password', array('label' => __('Password')))->add('password', 'password_confirm', array('label' => __('Confirm password')))->add('submit', 'submit', array('label' => __('Save')))->add_rule('email', 'required', __('You must enter an email'))->add_rule('email', 'valid::email', __('Email address is not valid'))->add_rule('password', 'matches[password_confirm]', __('The passwords doesn\'t match'));
     if ($form->validate()) {
         $user->username = $form->username->value;
         $user->email = $form->email->value;
         if (!empty($form->password->value)) {
             $user->password = $form->password->value;
         }
         $user->save();
         message::info(__('User edited successfully'), 'admin/user');
     }
     $this->template->content = View::factory('user/edit', $form->get(TRUE));
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:20,代码来源:user.php

示例8: change_client

 public function change_client($id = NULL)
 {
     $contact = ORM::factory('contact', $id);
     if ($contact->id == '') {
         $this->session->set_flash('contact', 'There is no contact associated with the id provided.');
         url::redirect();
     }
     $clients = $this->cache->get('client') ? $this->cache->get('client') : ORM::factory('client')->find_all_as_array();
     // $client_list = array();
     foreach ($clients as $client) {
         $client_list[$client['id']] = $client['company'];
     }
     $form = Formo::factory('contact_edit')->set('class', 'smart-form')->add_select('client', $client_list, array('value' => $contact->client_id))->add('submit', 'Submit');
     if ($form->validate()) {
         $contact->client_id = $form->client->value;
         $contact->save() and $this->cache->delete_tag('contacts') and url::redirect('clients');
     }
     $this->template->content = new View('contacts/add');
     $this->template->content->form = $form;
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:20,代码来源:contacts.php

示例9: edit

 public function edit($id)
 {
     $comment = ORM::factory('blog_comment', (int) $id);
     if (!$comment->loaded) {
         message::error(__('Invalid ID'), 'admin/blog');
     }
     $this->head->title->append(__('Edit comment #%id', array('%id' => $comment->id)));
     $this->template->title .= __('Edit comment #%id', array('%id' => $comment->id));
     $form = Formo::factory()->plugin('csrf')->add('text', 'author', array('label' => __('Author'), 'value' => $comment->author))->add('text', 'email', array('label' => __('Email'), 'value' => $comment->email))->add('text', 'url', array('label' => __('Homepage'), 'value' => $comment->url))->add('textarea', 'content', array('label' => __('Comment'), 'value' => $comment->content))->add('submit', 'submit', array('label' => __('Save')));
     if ($form->validate()) {
         $comment->author = $form->author->value;
         $comment->email = $form->email->value;
         $comment->url = $form->url->value;
         $comment->content = $form->content->value;
         $comment->save();
         Cache::instance()->delete('s7n_blog_feed_comments');
         message::info(__('Comment edited successfully'), 'admin/blog/comments/view/' . $comment->blog_post_id);
     }
     $this->template->content = View::factory('blog/editcomment', $form->get(TRUE));
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:20,代码来源:comments.php

示例10: index

 public function index()
 {
     // If remember me is set the autologin
     if ($this->auth->auto_login() || $this->auth->logged_in()) {
         url::redirect('dashboard');
     }
     $form = Formo::factory('login')->set('class', 'smart-form')->add('username', array('class' => 'size hasDefault'))->add_rule('username', 'required', __('You must enter a username'))->add('password', array('class' => 'size hasDefault'))->type('password')->add_rule('password', 'required', __('You must enter a password'))->add('checkbox', 'remember_me', array('label' => 'remember me', 'tabindex' => 3, 'required' => FALSE))->add('submit', 'submit', array('value' => __('Login'), 'class' => 'button'));
     if ($form->validate()) {
         // Remember me check
         $remember = isset($form->remember_me) ? TRUE : FALSE;
         // Load the user
         $user = ORM::factory('user', $form->username->value);
         // Attempt a login
         if ($this->auth->login($user, $form->password->value, $remember)) {
             url::redirect('dashboard');
         }
         $error = __('Invalid username or password');
     }
     $this->template->content = View::factory('login/index', $form->get(TRUE));
     $this->template->content->error = isset($error) ? $error : '';
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:21,代码来源:login.php

示例11: login

 public function login()
 {
     if (Auth::instance()->logged_in()) {
         if (Auth::instance()->logged_in('admin')) {
             url::redirect('admin');
         } else {
             url::redirect();
         }
     }
     $form = Formo::factory()->add('text', 'username', array('label' => __('Username')))->add('password', 'password', array('label' => __('Password')))->add('submit', 'submit', array('label' => __('Login')))->add_rule('username', 'required', __('You must enter a username'))->add_rule('password', 'required', __('You must enter a password'));
     if ($form->validate()) {
         // Load the user
         $user = ORM::factory('user', $form->username->value);
         // Attempt a login
         if ($user->loaded and Auth::instance()->login($user, $form->password->value)) {
             $url = Session::instance()->get_once('redirect_me_to');
             url::redirect(empty($url) ? 'admin' : $url);
         }
         $error = __('Invalid username or password');
     }
     $view = View::factory('login', $form->get(TRUE))->bind('error', $error);
     echo $view;
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:23,代码来源:auth.php

示例12: edit

 /**
  * Edit a $this->model_name
  * @Developer brandon
  * @Date Apr 21, 2010
  */
 public function edit($id = NULL)
 {
     $item = ORM::factory($this->model_name, (string) $id);
     $form = Formo::factory()->plugin('orm')->plugin('habtm')->orm($this->model_name, $id)->set('action', $item->update_path());
     // Add the related objects
     if ($this->show_habtm) {
         foreach ($item->has_and_belongs_to_many as $relationship) {
             $form->habtm($this->model_name, inflector::singular($relationship));
         }
     }
     // Add the submit button
     $form->add('submit');
     if (!$item->loaded) {
         flash::set_error('The ' . format::friendly_model_name($this->model_name) . ' you were looking for was not found');
         url::redirect($this->directory . '/index');
     }
     $this->template->set('content', View::factory($this->directory . '/edit')->set('form', $form)->set($this->model_name, $item));
 }
开发者ID:ready4god2513,项目名称:scs,代码行数:23,代码来源:crud.php

示例13: edit

 /**
  * Edit a $this->model_name
  * @Developer brandon
  * @Date Apr 21, 2010
  */
 public function edit($id = NULL)
 {
     $item = ORM::factory($this->model_name, $id);
     $form = Formo::factory()->plugin('orm')->orm($this->model_name, $id)->set('action', $item->update_path())->add('submit');
     if (!$item->loaded) {
         flash::set_error('The ' . format::friendly_model_name($this->model_name) . ' you were looking for was not found');
         url::redirect($this->directory . '/index');
     }
     $this->template->set('content', View::factory($this->directory . '/edit')->set('form', $form)->set($this->model_name, $item));
 }
开发者ID:ready4god2513,项目名称:Journal,代码行数:15,代码来源:crud.php

示例14: demo8

 public function demo8()
 {
     $hobbies = array('_blank_' => '', 'Run' => 'run', 'Jump' => 'jump', 'Swim' => 'swim');
     $skills = array(1 => 'poet', 25 => 'artist', 3 => 'television');
     $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     $form = Formo::factory()->plugin('ajaxval')->add('autocomplete', 'month', array('data' => implode('|', $months)))->add_html('<div style="height:20px"></div>', 'space1')->add('username')->add('password', 'password')->add('password', 'password2')->label('Confirm Password')->rule('matches[password]', 'Does not match')->add_html('<div style="height:20px"></div>', 'space2')->add('email')->add('phone')->add_select('hobbies', $hobbies)->add_group('skills[]', $skills)->add('textarea', 'notes')->add_submit('submit');
     $this->content = $form;
     $form->validate() and $this->_success();
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:9,代码来源:formo_demo.php

示例15: settings

 public function settings()
 {
     $this->head->title->append(__('Settings'));
     $this->template->title .= __('Settings');
     $form = Formo::factory()->plugin('csrf')->add('text', 'items_per_page', array('label' => __('Blog entries per page'), 'value' => config::get('blog.items_per_page')))->add('checkbox', 'enable_captcha', array('label' => __('Enable captcha'), 'checked' => config::get('blog.enable_captcha') === 'yes'))->add('checkbox', 'enable_tagcloud', array('label' => __('Enable tag cloud'), 'checked' => config::get('blog.enable_tagcloud') === 'yes'))->add('checkbox', 'comment_status', array('label' => __('Enable comments'), 'checked' => config::get('blog.comment_status') === 'open'))->add('submit', 'submit', array('label' => __('Save')))->add_rule('items_per_page', 'required', __('Please enter a number'))->add_rule('items_per_page', 'digit', __('This must be a number'));
     if ($form->validate()) {
         config::set('blog.enable_captcha', $form->enable_captcha->checked ? 'yes' : 'no');
         config::set('blog.enable_tagcloud', $form->enable_tagcloud->checked ? 'yes' : 'no');
         config::set('blog.comment_status', $form->comment_status->checked ? 'open' : 'closed');
         config::set('blog.items_per_page', $form->items_per_page->value);
         message::info(__('Settings changed successfully'), 'admin/blog/settings');
     }
     $this->template->content = new View('blog/settings', $form->get(TRUE));
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:14,代码来源:blog.php


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