[ Index ] |
|
Code source de PHPonTrax 2.6.6-svn |
[Code source] [Imprimer] [Statistiques]
File containing ActiveRecordHelper class and support functions (PHP 5)
Copyright: | (c) 2005 John Peterson |
Version: | $Id: active_record_helper.php 250 2006-08-25 15:56:48Z john $ |
Poids: | 722 lignes (27 kb) |
Inclus ou requis: | 1 fois |
Référencé: | 0 fois |
Nécessite: | 0 fichiers |
ActiveRecordHelper:: (30 méthodes):
input()
input_scaffolding()
form()
error_message_on()
error_messages_for()
all_input_tags()
default_input_block()
to_tag()
to_scaffold_tag()
tag_without_error_wrapping()
tag()
content_tag_without_error_wrapping()
content_tag()
to_date_select_tag_without_error_wrapping()
to_date_select_tag()
to_datetime_select_tag_without_error_wrapping()
to_datetime_select_tag()
error_message()
column_type()
pagination_limit_select()
pagination_links()
pagination_range_text()
error_message_on()
error_messages_for()
form()
input()
input_scaffolding()
pagination_limit_select()
pagination_links()
pagination_range_text()
Classe: ActiveRecordHelper - X-Ref
input($object_name, $attribute_name, $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"): input("post", "title") => <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> |
input_scaffolding($object_name, $attribute_name, $options = array() X-Ref |
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): 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. Example (entry is a new record that has a message attribute using VARCHAR): form("entry", array('action' => "sign", 'input_block' => 'foreach($record->content_columns() as $column_name => $column) $contents .= Inflector::humanize($column_name) . ": " . input($record, $column) . "<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> It's also possible to add additional content to the form by giving it a block, such as: form("entry", array('action' => "sign", 'block' => content_tag("b", "Department") . collection_select("department", "id", $departments, "id", "name")) ) |
error_message_on($object_name, $attribute_name, $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): <?= error_message_on("post", "title") ?> => <div class="formError">can't be empty</div> <?= 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) param: mixed object_name The name of a PHP class, or param: string[] options Set of options: 'header_tag', 'id', 'class' |
all_input_tags($record, $record_name, $options) X-Ref |
default_input_block() X-Ref |
to_tag($object_name, $attribute_name, $options = array() X-Ref |
param: string object_name Name of an ActiveRecord subclass param: string attribute_name Name of an attribute of $object_name param: string[] options |
to_scaffold_tag($object_name, $attribute_name, $options = array() X-Ref |
tag_without_error_wrapping() X-Ref |
tag($name, $options = array() X-Ref |
content_tag_without_error_wrapping() X-Ref |
content_tag($name, $value, $options = array() X-Ref |
to_date_select_tag_without_error_wrapping() X-Ref |
to_date_select_tag($options = array() X-Ref |
to_datetime_select_tag_without_error_wrapping() X-Ref |
to_datetime_select_tag($options = array() X-Ref |
error_message() X-Ref |
column_type() X-Ref |
pagination_limit_select($object_name_or_object, $default_text = "per page:") X-Ref |
Paging html functions |
pagination_links($object_name_or_object) X-Ref |
return: string HTML to link to previous and next pages |
pagination_range_text($object_name_or_object, $format = "Showing %d - %d of %d items.") X-Ref |
Pas de description |
error_message_on() X-Ref |
Avialble functions for use in views error_message_on($object, $attribute_name, $prepend_text = "", $append_text = "", $css_class = "formError") |
error_messages_for() X-Ref |
error_messages_for($object_name, $options = array()) |
form() X-Ref |
form($record_name, $options = array()) |
input() 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"): input("post", "title") => <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> |
input_scaffolding() X-Ref |
pagination_limit_select() X-Ref |
pagination_links() X-Ref |
pagination_range_text() X-Ref |
Généré le : Sun Feb 25 20:04:38 2007 | par Balluche grâce à PHPXref 0.7 |