[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/AkActionView/helpers/ -> active_record_helper.php (summary)

(no description)

Author: Bermi Ferrer
Copyright: Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
License: GNU Lesser General Public License
File Size: 321 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 AkActionView/helpers/form_helper.php

Defines 2 classes

ActiveRecordHelper:: (6 methods):
  input()
  form()
  error_message_on()
  error_messages_for()
  all_input_tags()
  default_input_block()

ActiveRecordInstanceTag:: (16 methods):
  ActiveRecordInstanceTag()
  to_tag()
  tag()
  tag_without_error_wrapping()
  content_tag()
  content_tag_without_error_wrapping()
  to_date_select_tag()
  to_date_select_tag_without_error_wrapping()
  to_datetime_select_tag()
  to_datetime_select_tag_without_error_wrapping()
  to_check_box_tag()
  to_check_box_tag_without_error_wrapping()
  error_wrapping()
  error_message()
  get_column_type()
  _getColumnName()


Class: ActiveRecordHelper  - X-Ref

The Active Record Helper makes it easier to create forms for records kept in instance variables. The most far-reaching is the form
method that creates a complete form for all the basic content types of the record (not associations or aggregations, though). This
is a great of making the record quickly available for editing, but likely to prove lackluster for a complicated real-world form.
In that case, it's better to use the input method and the specialized form methods from the FormHelper

input($record_name, $method, $options = array()   X-Ref
Returns a default input tag for the type of object returned by the method. Example
(title is a VARCHAR column and holds "Hello World"):
$active_record_helper->input('post', 'title'); =>
<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />


form($record_name, $options = array()   X-Ref
Returns an entire form with input tags and everything for a specified Active Record object. Example
(post is a new record that has a title using VARCHAR and a body using TEXT):
$active_record_helper->form('post'); =>
<form action='/post/create' method='post'>
<p>
<label for="post_title">Title</label><br />
<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
</p>
<p>
<label for="post_body">Body</label><br />
<textarea cols="40" id="post_body" name="post[body]" rows="20">
Back to the hill and over it again!
</textarea>
</p>
<input type='submit' value='Create' />
</form>

It's possible to specialize the form builder by using a different action name and by supplying another
block renderer that will be evaled by PHP.
Example (entry is a new record that has a message attribute using VARCHAR):

$active_record_helper->form('entry', array('action'=>'sign','input_block' =>
'<p><?=AkInflector::humanize($column)?>: <?=$this->input($record_name, $column)?></p><br />'
);

<form action='/post/sign' method='post'>
Message:
<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /><br />
<input type='submit' value='Sign' />
</form>

error_message_on($object_name, $method, $prepend_text = '', $append_text = '', $css_class = 'formError')   X-Ref
Returns a string containing the error message attached to the +method+ on the +object+, if one exists.
This error message is wrapped in a DIV tag, which can be specialized to include both a +prepend_text+ and +append_text+
to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message
"can't be empty" on the title attribute):

<?= $active_record_helper->error_message_on('post', 'title'); ?>
<div class="formError">can't be empty</div>

<?=$active_record_helper->error_message_on('post','title','Title simply ', " (or it won't work)", 'inputError') ?> =>
<div class="inputError">Title simply can't be empty (or it won't work)</div>

error_messages_for($object_name, $options = array()   X-Ref
Returns a string with a div containing all the error messages for the object located as an instance variable by the name
of <tt>object_name</tt>. This div can be tailored by the following options:

* <tt>header_tag</tt> - Used for the header of the error div (default: h2)
* <tt>id</tt> - The id of the error div (default: errorExplanation)
* <tt>class</tt> - The class of the error div (default: errorExplanation)

NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
you need is significantly different from the default presentation, it makes plenty of sense to access the $object->getErrors()
instance yourself and set it up. View the source of this method to see how easy it is.

all_input_tags(&$record, $record_name, $options = array()   X-Ref
No description

default_input_block()   X-Ref
No description

Class: ActiveRecordInstanceTag  - X-Ref

ActiveRecordInstanceTag($object_name, $column_name, &$template_object)   X-Ref
No description

to_tag($options = array()   X-Ref
No description

tag($name, $options)   X-Ref
No description

tag_without_error_wrapping($name, $options)   X-Ref
No description

content_tag($name, $value, $options)   X-Ref
No description

content_tag_without_error_wrapping($name, $value, $options)   X-Ref
No description

to_date_select_tag($options = array()   X-Ref
No description

to_date_select_tag_without_error_wrapping($options = array()   X-Ref
No description

to_datetime_select_tag($options = array()   X-Ref
No description

to_datetime_select_tag_without_error_wrapping($options = array()   X-Ref
No description

to_check_box_tag($options = array()   X-Ref
No description

to_check_box_tag_without_error_wrapping($options = array()   X-Ref
No description

error_wrapping($html_tag, $has_error)   X-Ref
No description

error_message()   X-Ref
No description

get_column_type()   X-Ref
No description

_getColumnName($column_name, $object_name, &$template_object)   X-Ref
No description



Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6