本文整理汇总了PHP中Formo类的典型用法代码示例。如果您正苦于以下问题:PHP Formo类的具体用法?PHP Formo怎么用?PHP Formo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Formo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: html
public function html()
{
foreach ($this->_field->get('options') as $label => $options) {
$this->_field->append(Formo::field($label, 'option', $options));
}
$this->_view->set_var('tag', 'optgroup')->attr('label', $this->_field->alias());
}
开发者ID:kanikaN,项目名称:qload,代码行数:7,代码来源:optgroup.php
示例3: html
public function html()
{
foreach ($this->field->get('options') as $label => $options) {
$this->field->append(Formo::field($label, 'option', $options));
}
$this->decorator->set('tag', 'select')->attr('name', $this->name());
}
开发者ID:justus,项目名称:kohana-formo,代码行数:7,代码来源:core.php
示例4: 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
示例5: html
public function html()
{
foreach ($this->_field->get('options') as $alias => $options)
{
$this->_field->append(Formo::field($alias, 'checkbox', $options));
}
}
开发者ID:refo,项目名称:kohana,代码行数:7,代码来源:checkboxes.php
示例6: html
public function html()
{
foreach ($this->_field->get('options') as $label => $options)
{
$this->_field->append(Formo::field($label, 'radio', $options));
}
}
开发者ID:refo,项目名称:kohana,代码行数:7,代码来源:radios.php
示例7: html
public function html()
{
$this->render_field->append(Formo::field('', 'option'));
foreach ($this->render_field->options as $label => $options) {
$this->render_field->append(Formo::field($label, 'option', $options));
}
$this->render_field->set('tag', 'select')->attr('name', $this->field->alias());
}
开发者ID:salesignighter,项目名称:kohana-formo,代码行数:8,代码来源:core.php
示例8: _get_val
protected function _get_val()
{
$new_value = $this->_field->get('new_value');
if (Formo::is_set($new_value) === TRUE) {
return $new_value;
}
return ($val = $this->_field->get('value')) ? $val : array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => '', 'size' => '');
}
开发者ID:kanikaN,项目名称:qload,代码行数:8,代码来源:file.php
示例9: shortcut
public static function shortcut($defs, $value, $tag = 'h3', $props = NULL)
{
$name = strtolower(str_replace(' ', '_', $value));
$info = self::process_info($defs, array(), $name);
$info['tags'] = array('<' . $tag . Formo::quicktagss($props) . '>', '</' . $tag . '>');
$info['value'] = $value;
return new Formo_h_Driver($name, $info);
}
开发者ID:carriercomm,项目名称:billing_cart,代码行数:8,代码来源:h.php
示例10: getval
public function getval()
{
// If the form was sent but the field wasn't set, return empty array as value
if ($this->field->sent() and Formo::notset($this->field->get('new_value'))) {
return FALSE;
}
// Otherwise return the value that's set
return !Formo::notset($this->field->get('new_value')) ? (bool) $this->field->get('new_value') : (bool) $this->field->get('value');
}
开发者ID:salesignighter,项目名称:kohana-formo,代码行数:9,代码来源:core.php
示例11: checked
public function checked()
{
$parent_newval = $this->field->parent()->get('new_value');
$parent_value = $this->field->parent()->get('value');
if (Formo::is_set($parent_newval) === FALSE and !$this->field->parent(Formo::PARENT)->sent()) {
return in_array($this->val(), (array) $parent_value);
}
return in_array($this->field->val(), (array) $parent_newval);
}
开发者ID:justus,项目名称:kohana-formo,代码行数:9,代码来源:core.php
示例12: _get_val
protected function _get_val()
{
$new_value = $this->_field->get('new_value');
// If the form was sent but the field wasn't set, return FALSE
if ($this->_field->sent() and Formo::is_set($new_value) === FALSE) {
return FALSE;
}
// Otherwise return the value that's set
return Formo::is_set($new_value) === TRUE ? (bool) $new_value : (bool) $this->_field->get('value');
}
开发者ID:kanikaN,项目名称:qload,代码行数:10,代码来源:bool.php
示例13: blank
public function blank($element = '', $list = FALSE)
{
$form = Formo::instance($this->formo_name);
$list = !$list ? $element : $list;
$element = $list ? $element : Formo::$last_accessed;
if (!is_array($list)) {
$list = TRUE;
}
$form->{$this->name}->blank = $list;
}
开发者ID:ready4god2513,项目名称:Journal,代码行数:10,代码来源:select.php
示例14: __construct
/**
* Create a new field
*
* @access public
* @param mixed $alias
* @param mixed $driver. (default: NULL)
* @param mixed array $options. (default: NULL)
* @return void
*/
public function __construct($alias, $driver = NULL, $value = NULL, array $options = NULL)
{
$options = func_get_args();
$orig_options = $options;
$options = Formo::args(__CLASS__, __FUNCTION__, $options);
// Add all the options to the object
$this->load_options($options);
// Run the driver's post_construct() method
$this->driver()->post_construct();
}
开发者ID:justus,项目名称:kohana-formo,代码行数:19,代码来源:core.php
示例15: check
public function check($group, $element = '')
{
$form = Formo::instance($this->formo_name);
if (is_object($form->{$group}) and get_class($form->{$group}) == 'Formo_Group') {
foreach (Formo::splitby($element) as $el) {
$form->{$group}->{$el}->checked = TRUE;
}
} else {
$form->{$group}->checked = TRUE;
}
}
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:11,代码来源:radio.php
示例16: label
/**
* Retrieve the label text
*
* @access public
* @return void
*/
public function label($utf8 = FALSE)
{
$label = ($label = $this->_field->get('label'))
? $label
: $this->_field->alias();
// Translate if needed
return (Formo::config($this->_field, 'translate') === TRUE)
? __($label)
: $label;
}
开发者ID:refo,项目名称:kohana,代码行数:17,代码来源:view.php
示例17: _add_input_rules
protected function _add_input_rules()
{
// Grab the rules from the formo config
$rules = Formo::config($this->_field, 'input_rules.' . $this->get_type());
if ($rules) {
// Attach rules to the field's parent
$this->_field->parent()->rules($this->_field->alias(), $rules);
}
if ($bindings = Formo::config($this->_field, 'formo.html5_bindings.' . $this->get_type())) {
$this->_field->set('bindings', $bindings);
}
}
开发者ID:kanikaN,项目名称:qload,代码行数:12,代码来源:input.php
示例18: render
public function render()
{
$sel = '';
$sel .= '<select name="' . $this->name . '"' . Formo::quicktagss($this->_find_tags()) . ">" . "\n";
foreach ($this->values as $k => $v) {
$k = preg_replace('/_[bB][lL][aA][nN][kK][0-9]*_/', '', $k);
$selected = $v == $this->value ? " selected='selected'" : '';
$sel .= "\t\t" . '<option value="' . $v . '"' . $selected . '>' . $k . '</option>' . "\n";
}
$sel .= "</select>";
return $sel;
}
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:12,代码来源:select.php
示例19: translate
public function translate($str)
{
$new_str = $str;
if (Formo::config($this->_field, 'use_messages') === TRUE) {
$msg_file = Formo::config($this->_field, 'message_file');
$new_str = Kohana::message($msg_file, $str, $str);
}
if (Formo::config($this->_field, 'translate') === TRUE) {
$new_str = __($new_str);
}
return $new_str;
}
开发者ID:kanikaN,项目名称:qload,代码行数:12,代码来源:view.php
示例20: 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
注:本文中的Formo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论