本文整理汇总了PHP中Formo类的典型用法代码示例。如果您正苦于以下问题:PHP Formo类的具体用法?PHP Formo怎么用?PHP Formo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Formo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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());
}
示例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());
}
示例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));
}
示例5: html
public function html()
{
foreach ($this->_field->get('options') as $alias => $options)
{
$this->_field->append(Formo::field($alias, 'checkbox', $options));
}
}
示例6: html
public function html()
{
foreach ($this->_field->get('options') as $label => $options)
{
$this->_field->append(Formo::field($label, 'radio', $options));
}
}
示例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());
}
示例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' => '');
}
示例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);
}
示例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');
}
示例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);
}
示例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');
}
示例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;
}
示例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();
}
示例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;
}
}